11from ROOT
import Belle2
17from b2test_utils
import safe_process, clean_working_directory
19basf2.set_random_seed(
"something important")
21testFile =
'b2filemetadata.root'
23with clean_working_directory():
27 main.add_module(
'EventInfoSetter', evtNumList=[9, 1], runList=[1, 15], expList=[7, 7])
28 main.add_module(
'RootOutput', outputFileName=testFile, updateFileCatalog=
False)
33 read.add_module(
'RootInput', inputFileName=testFile)
39 assert 10 == metadata.getNEvents()
40 assert 10 == metadata.getNFullEvents()
42 assert 7 == metadata.getExperimentLow()
43 assert 1 == metadata.getRunLow()
44 assert 1 == metadata.getEventLow()
45 assert 7 == metadata.getExperimentHigh()
46 assert 15 == metadata.getRunHigh()
47 assert 1 == metadata.getEventHigh()
48 assert metadata.containsEvent(7, 1, 1)
49 assert metadata.containsEvent(7, 1, 9)
50 assert metadata.containsEvent(7, 15, 1)
51 assert metadata.containsEvent(7, 1, 10)
52 assert metadata.containsEvent(7, 3, 6)
53 assert not metadata.containsEvent(7, 0, 10)
54 assert not metadata.containsEvent(7, 16, 6)
55 assert not metadata.containsEvent(0, 15, 6)
57 assert 0 == metadata.getNParents()
62 assert "something important" == metadata.getRandomSeed()
64 assert get_version() == metadata.getRelease()
65 assert metadata.getSteering().startswith(
'#!/usr/bin/env python3')
66 assert metadata.getSteering().strip().endswith(
'dummystring')
67 assert 10 == metadata.getMcEvents()
69 os.system(
'touch Belle2FileCatalog.xml')
70 assert 0 == os.system(
'b2file-metadata-add --lfn /logical/file/name ' + testFile)
72 assert 0 == os.system(
'b2file-metadata-show ' + testFile)
75 metadata_output = subprocess.check_output([
'b2file-metadata-show',
'--json', testFile])
76 m = json.loads(metadata_output.decode(
'utf-8'))
77 assert 7 == m[
'experimentLow']
78 assert 1 == m[
'runLow']
79 assert 1 == m[
'eventLow']
80 assert 7 == m[
'experimentHigh']
81 assert 15 == m[
'runHigh']
82 assert 1 == m[
'eventHigh']
83 assert 'something important' == m[
'randomSeed']
84 assert 10 == m[
'nEvents']
85 assert isinstance(m[
'nEvents'], int)
86 assert 10 == m[
'nFullEvents']
87 assert isinstance(m[
'nFullEvents'], int)
88 assert '/logical/file/name' == m[
'LFN']
a (simplified) python wrapper for StoreObjPtr.