HPS-MC
 
Loading...
Searching...
No Matches
test_tools_hpstr.py
Go to the documentation of this file.
1import unittest
2import configparser
3import os
4
5from hpsmc.tools import HPSTR
6
7
8class TestHPSTR(unittest.TestCase):
9
10 def test_init(self):
11 hpstr = HPSTR()
12 self.assertEqual(hpstr.name, 'hpstr')
13 self.assertEqual(hpstr.command, 'hpstr')
14 self.assertEqual(hpstr.is_data, 0)
15
17 hpstr = HPSTR()
18 self.assertEqual(hpstr.required_parameters(), ['config_files'])
19
21 hpstr = HPSTR()
22 self.assertEqual(hpstr.optional_parameters(), ['year', 'is_data', 'nevents', 'tracking'])
23
25 hpstr = HPSTR()
26 self.assertEqual(hpstr.required_config(), ['hpstr_install_dir', 'hpstr_base'])
27
28 def test_setup(self):
29 hpstr = HPSTR(cfg='config', inputs=['some/path/to/input.root'], outputs=['some/path/to/output.root'])
30 parser = configparser.ConfigParser()
31 config_file = ['test_helpers/.hpsmc_test_cfg']
32 parser.read(config_file)
33 hpstr.config(parser)
34 params = {'config_files': {'config': 'config.py'}}
35 hpstr.set_parameters(params)
36
37 hpstr.setup()
38 self.assertEqual(hpstr.env_script, 'test_helpers/hpstrdir/install/bin/hpstr-env.sh')
39 self.assertEqual(hpstr.cfg_path, 'test_helpers/hpstrdir/processors/config/config.py')
40 self.assertEqual(hpstr.append_tok, 'config')
41
43 hpstr = HPSTR(cfg='appended_config', inputs=['some/path/to/input.root'], outputs=['some/path/to/output.root'])
44 parser = configparser.ConfigParser()
45 config_file = ['test_helpers/.hpsmc_test_cfg']
46 parser.read(config_file)
47 hpstr.config(parser)
48 params = {'config_files': {'appended_config': 'config.py'}}
49 hpstr.set_parameters(params)
50 hpstr.setup()
51 self.assertEqual(hpstr.output_files(), ['some/path/to/input_appended_config.root'])
52
54 hpstr = HPSTR(cfg='appended_config', inputs=['some/path/to/input.slcio'], outputs=['some/path/to/output.root'])
55 parser = configparser.ConfigParser()
56 config_file = ['test_helpers/.hpsmc_test_cfg']
57 parser.read(config_file)
58 hpstr.config(parser)
59 params = {'config_files': {'appended_config': 'config.py'}}
60 hpstr.set_parameters(params)
61 hpstr.setup()
62 self.assertEqual(hpstr.output_files(), ['some/path/to/input.root'])
63
64 def test_cmd_args(self):
65 hpstr = HPSTR(cfg='config', inputs=['some/path/to/input.root'], outputs=['some/path/to/output.root'])
66
67 parser = configparser.ConfigParser()
68 config_file = ['test_helpers/.hpsmc_test_cfg']
69 parser.read(config_file)
70 hpstr.config(parser)
71 params = {'config_files': {'config': 'config.py'}, 'nevents': 1000, 'year': 10}
72 hpstr.set_parameters(params)
73 hpstr.setup()
74
75 self.assertEqual(hpstr.cmd_args(), ["test_helpers/hpstrdir/processors/config/config.py", "-t", "0", "-i", "some/path/to/input.root", "-o", "some/path/to/input_config.root", "-n", "1000", "-y", "10"])
76
77
78if __name__ == '__main__':
79 unittest.main()
Run the hpstr analysis tool.
Definition tools.py:344
Tools that can be used in HPSMC jobs.
Definition tools.py:1