16Test the b2cal-extend-eventdependency-tool.
20if __name__ ==
'__main__':
27 database_location =
'testingdb/testingdb.txt'
28 basf2.conditions.expert_settings(save_payloads=database_location)
31 beamspot = ROOT.Belle2.BeamSpot()
32 event_object = ROOT.Belle2.EventDependency(beamspot)
33 database = ROOT.Belle2.Database.Instance()
34 iov = ROOT.Belle2.IntervalOfValidity.always()
35 created = database.storeData(
'BeamSpot', event_object, iov)
37 basf2.B2FATAL(
'Something went wrong when creating the payload for the test')
40 payload_file = glob.glob(f
'{basf2.find_file(os.path.dirname(database_location))}/*root')[0]
44 result = subprocess.run([
'b2cal-extend-eventdependency-payload',
'-i',
'foo.bar',
45 '-n',
'BeamSpot',
'--iov',
'1',
'2',
'3',
'4',
'--output_db',
46 f
'{database_location}'])
47 assert(
not result.returncode == 0)
49 result = subprocess.run([
'b2cal-extend-eventdependency-payload',
'-i', f
'{payload_file}',
50 '-n',
'FooBar',
'--iov',
'1',
'2',
'3',
'4',
'--output_db',
51 f
'{database_location}'])
52 assert(
not result.returncode == 0)
54 result = subprocess.run([
'b2cal-extend-eventdependency-payload',
'-i', f
'{payload_file}',
55 '-n',
'BeamSpot',
'--iov',
'1',
'2',
'3',
'--output_db',
56 f
'{database_location}'])
57 assert(
not result.returncode == 0)
59 result = subprocess.run([
'b2cal-extend-eventdependency-payload',
'-i', f
'{payload_file}',
60 '-n',
'BeamSpot',
'--iov',
'1',
'2',
'3',
'4',
'--output_db',
62 assert(
not result.returncode == 0)
65 result = subprocess.run([
'b2cal-extend-eventdependency-payload',
'-i', f
'{payload_file}',
66 '-n',
'BeamSpot',
'--iov',
'1',
'2',
'3',
'4',
'--output_db',
67 f
'{database_location}'])
68 assert(result.returncode == 0)
71 with open(database_location)
as f:
75 fields = line.split(
' ')
76 assert(fields[0] ==
'dbstore/BeamSpot')
79 assert(fields[2].strip() ==
'0,0,-1,-1')
81 elif line_number == 1:
82 assert(fields[2].strip() ==
'1,2,3,4')
def clean_working_directory()