9Check the revision number of a payload used by a module.
15import b2test_utils
as b2tu
16from ROOT
import Belle2
17import ROOT.Belle2
as B2
22 Small module for checking some payload metadata.
25 def __init__(self, use_testing_payloads, md5_revision):
39 assert (
'testingdb/testingdb.txt' in self.
beam_parameters.getGlobaltag())
41 assert (os.path.basename(self.
beam_parameters.getFilename()).startswith(
'dbstore'))
43 assert (self.
beam_parameters.getIoV() == B2.IntervalOfValidity(0, 1, 2, 3))
45 assert (self.
beam_parameters.getGlobaltag() == b2.conditions.default_globaltags[0])
48 assert (self.
beam_parameters.getIoV() == B2.IntervalOfValidity(0, 0, 0, -1))
51def create_beam_parameters_payload(testing_database_path):
53 Create locally a BeamParameters payload.
55 b2.conditions.expert_settings(save_payloads=testing_database_path)
56 beam_parameters = B2.BeamParameters()
57 database = B2.Database.Instance()
58 iov = B2.IntervalOfValidity(0, 1, 2, 3)
59 assert (database.storeData(
'BeamParameters', beam_parameters, iov))
62def testing_path(use_testing_payloads=False, remove_default_globaltag=False, testing_database_path=None, md5_revision=None):
64 The basf2 steering path for this test.
66 if remove_default_globaltag:
67 b2.conditions.override_globaltags()
68 if use_testing_payloads:
69 b2.conditions.prepend_testing_payloads(b2.find_file(testing_database_path))
70 testing_path = b2.Path()
71 testing_path.add_module(
'EventInfoSetter', expList=[0], runList=[1])
72 testing_path.add_module(
CheckPayloadMetadata(use_testing_payloads=use_testing_payloads, md5_revision=md5_revision))
73 b2.process(testing_path)
76if __name__ ==
'__main__':
78 with b2tu.clean_working_directory():
81 testing_database_path =
'testingdb/testingdb.txt'
84 assert (b2tu.run_in_subprocess(target=create_beam_parameters_payload, testing_database_path=testing_database_path) == 0)
89 with open(b2.find_file(
'testingdb/testingdb.txt'))
as testing_database_file:
90 for line
in testing_database_file:
91 md5_revision = str(line.split(
' ')[1])
94 assert (b2tu.run_in_subprocess(target=testing_path,
95 use_testing_payloads=
False,
96 remove_default_globaltag=
True,
100 assert (b2tu.run_in_subprocess(target=testing_path,
101 use_testing_payloads=
False,
102 remove_default_globaltag=
False,
106 assert (b2tu.run_in_subprocess(target=testing_path,
107 use_testing_payloads=
True,
108 remove_default_globaltag=
True,
109 testing_database_path=testing_database_path,
110 md5_revision=md5_revision,
114 assert (b2tu.run_in_subprocess(target=testing_path,
115 use_testing_payloads=
True,
116 remove_default_globaltag=
False,
117 testing_database_path=testing_database_path,
118 md5_revision=md5_revision,