Ejemplo n.º 1
0
 def test_non_existing_plugin_parse(self):
     config = {"plugins": ["foo", "bar"]}
     f_config_name = join(_basedir, "test_data/config_plugin_dict.yaml")
     f_config = open(f_config_name, "w")
     dump(config, f_config)
     f_config.close()
     self.assertRaises(IllegalArgumentError, ConfigParser.parse, f_config_name)
     os.remove(f_config_name)
Ejemplo n.º 2
0
 def test_non_existing_plugin_key_parse(self):
     config = {"det1": {"mass": "100 kg"}, "NoOfPrimaries": 10}
     f_config_name = join(_basedir, "test_data/config_no_plugin.yaml")
     f_config = open(f_config_name, "w")
     dump(config, f_config)
     f_config.close()
     self.assertRaises(IllegalArgumentError, ConfigParser.parse, f_config_name)
     os.remove(f_config_name)
Ejemplo n.º 3
0
 def test_non_existing_plugin_parse(self):
     config = {"plugins": ["foo", "bar"]}
     f_config_name = join(_basedir, "test_data/config_plugin_dict.yaml")
     f_config = open(f_config_name, "w")
     dump(config, f_config)
     f_config.close()
     self.assertRaises(IllegalArgumentError, ConfigParser.parse,
                       f_config_name)
     os.remove(f_config_name)
Ejemplo n.º 4
0
 def test_non_existing_plugin_key_parse(self):
     config = {"det1": {"mass": "100 kg"}, "NoOfPrimaries": 10}
     f_config_name = join(_basedir, "test_data/config_no_plugin.yaml")
     f_config = open(f_config_name, "w")
     dump(config, f_config)
     f_config.close()
     self.assertRaises(IllegalArgumentError, ConfigParser.parse,
                       f_config_name)
     os.remove(f_config_name)
Ejemplo n.º 5
0
 def setUp(self):
     self.f = open(join(_basedir, "test_data/test.yaml"), "w")
     self.f2 = open(join(_basedir, "test_data/test2.yaml"), "w")
     self.data = {"global": {"NoOfPrimaries": 10},
                  "plugins": {"a": [1, 2, 3]},
                  "detectors": {"det1": {"mass": "100 kg"}}}
     self.data2 = {"plugin": {"a": [1, 2, 3, 4]}}
     self.data3 = {"plugins": OrderedDict([(1, 0), (3, 1), (2, 4)])}
     dump(self.data, self.f)
     dump(self.data3, self.f2)
     _global_data._reset()
Ejemplo n.º 6
0
 def test_weight_parsing(self):
     config = {"global": {"weights": {"foo": 0.1, "bar": 0.8}}, "plugins": {}}
     f_config_name = join(_basedir, "test_data/config_weights.yaml")
     f_config = open(f_config_name, "w")
     dump(config, f_config)
     f_config.close()
     res = {"weights": {"foo": 0.1, "bar": 0.8}}
     parsed_config = ConfigParser.parse(f_config_name)
     print _global_data.__dict__
     self.assertEqual(_global_data, res)
     os.remove(f_config_name)
Ejemplo n.º 7
0
 def test_detector_parsing_types_global(self):
     config = {"global": {"NoOfPrimaries": "float:10"},
               "plugins": {"a": [1, 2, 3]}}
     f_config_name = join(_basedir, "test_data/config_type_global.yaml")
     f_config = open(f_config_name, "w")
     dump(config, f_config)
     f_config.close()
     res = {"NoOfPrimaries": 10.}
     config = ConfigParser.parse(f_config_name)
     self.assertEqual(_global_data, res)
     os.remove(f_config_name)
Ejemplo n.º 8
0
 def test_detector_parsing_types_global(self):
     config = {
         "global": {
             "NoOfPrimaries": "float:10"
         },
         "plugins": {
             "a": [1, 2, 3]
         }
     }
     f_config_name = join(_basedir, "test_data/config_type_global.yaml")
     f_config = open(f_config_name, "w")
     dump(config, f_config)
     f_config.close()
     res = {"NoOfPrimaries": 10.}
     config = ConfigParser.parse(f_config_name)
     self.assertEqual(_global_data, res)
     os.remove(f_config_name)
Ejemplo n.º 9
0
 def test_weight_parsing(self):
     config = {
         "global": {
             "weights": {
                 "foo": 0.1,
                 "bar": 0.8
             }
         },
         "plugins": {}
     }
     f_config_name = join(_basedir, "test_data/config_weights.yaml")
     f_config = open(f_config_name, "w")
     dump(config, f_config)
     f_config.close()
     res = {"weights": {"foo": 0.1, "bar": 0.8}}
     parsed_config = ConfigParser.parse(f_config_name)
     print _global_data.__dict__
     self.assertEqual(_global_data, res)
     os.remove(f_config_name)
Ejemplo n.º 10
0
 def setUp(self):
     self.f = open(join(_basedir, "test_data/test.yaml"), "w")
     self.f2 = open(join(_basedir, "test_data/test2.yaml"), "w")
     self.data = {
         "global": {
             "NoOfPrimaries": 10
         },
         "plugins": {
             "a": [1, 2, 3]
         },
         "detectors": {
             "det1": {
                 "mass": "100 kg"
             }
         }
     }
     self.data2 = {"plugin": {"a": [1, 2, 3, 4]}}
     self.data3 = {"plugins": OrderedDict([(1, 0), (3, 1), (2, 4)])}
     dump(self.data, self.f)
     dump(self.data3, self.f2)
     _global_data._reset()
Ejemplo n.º 11
0
 def testDump(self):
     f = open("testoy.yaml", "w")
     dump(self.d, f)
     f.close()