Skip to content
Snippets Groups Projects
Commit d96651a6 authored by Eduardo Rodrigues's avatar Eduardo Rodrigues
Browse files

Merge branch 'erodrigu-DaVinciSys-pytests-1' into 'master'

Add Pytest tests for the davinci script in DaVinciSys

See merge request !608
parents b5f5f18a ecd5f61d
No related branches found
No related tags found
2 merge requests!1103Draft: Add AnalysisHelpers to DaVinci Stack,!608Add Pytest tests for the davinci script in DaVinciSys
Pipeline #3352075 passed
......@@ -16,3 +16,4 @@ DaVinciSys
gaudi_install(SCRIPTS)
gaudi_add_tests(QMTest)
gaudi_add_tests(pytest ${CMAKE_CURRENT_SOURCE_DIR}/tests)
##############################################################################
# (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
##############################################################################
# (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
import subprocess, os
import pytest
def test_default():
"""
Check that the simple `davinci` command works.
"""
result = subprocess.run("davinci", shell=True)
assert result.returncode == 0
def test_invalid_option():
"""
Check that an unknown `davinci` option results in an exit code error.
"""
with pytest.raises(subprocess.CalledProcessError):
_ = subprocess.run("davinci --unknown", shell=True, check=True)
def test_override_job_option():
"""
Verify the overriding of a DaVinci option on the fly.
No need to actually run the job, hence the dry run.
"""
cmd = 'davinci --export test_override_job_option.opts --dry-run run-mc --overwrite_data_options True --unpack_stream "/Event/Unknown" --inputfiledb Upgrade_Bd2KstarMuMu -'
result = subprocess.run(cmd, shell=True)
# Just be maniac - the command should work ;-)
assert result.returncode == 0
# Inspect the produced .opts file and check for the option value overridden
with open("test_override_job_option.opts") as f:
assert any('.unpack_stream = "/Event/Unknown";' in line
for line in f.readlines())
os.remove("test_override_job_option.opts")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment