Пример #1
0
 def test_level1_spec(self):
     """Test generating a spec with one level
     """
     default = HierarchicalOrderedDict()
     default['a.b'] = 1.2
     self.assert_equal_encoded_list(
         ohm_to_spec(default),
         ["[a]", "b = float(default=1.2)"])
Пример #2
0
 def test_string_spec(self):
     """Test generating a spec from a string
     """
     default = HierarchicalOrderedDict()
     default['a'] = "bla"
     self.assert_equal_encoded_list(
         ohm_to_spec(default),
         ["a = string(default=bla)"])
Пример #3
0
 def test_float_spec(self):
     """Test generating a spec from a float
     """
     default = HierarchicalOrderedDict()
     default['a'] = 1.2
     self.assert_equal_encoded_list(
         ohm_to_spec(default),
         ["a = float(default=1.2)"])
Пример #4
0
 def test_int_spec(self):
     """Test generating a spec from an integer
     """
     default = HierarchicalOrderedDict()
     default['a'] = 12
     self.assert_equal_encoded_list(
         ohm_to_spec(default),
         ["a = integer(default=12)"])
Пример #5
0
 def test_boolean_spec(self):
     """Test generating a spec from a boolean
     """
     default = HierarchicalOrderedDict()
     default['a'] = True
     self.assert_equal_encoded_list(
         ohm_to_spec(default),
         ["a = boolean(default=True)"])
 def test_level1_spec(self):
     """Test generating a spec with one level
     """
     default = HierarchicalOrderedDict()
     default['a.b'] = 1.2
     self.assert_equal_encoded_list(
         ohm_to_spec(default),
         ["[a]", "b = float(default=1.2)"])
 def test_float_spec(self):
     """Test generating a spec from a float
     """
     default = HierarchicalOrderedDict()
     default['a'] = 1.2
     self.assert_equal_encoded_list(
         ohm_to_spec(default),
         ["a = float(default=1.2)"])
 def test_string_spec(self):
     """Test generating a spec from a string
     """
     default = HierarchicalOrderedDict()
     default['a'] = "bla"
     self.assert_equal_encoded_list(
         ohm_to_spec(default),
         ["a = string(default=bla)"])
 def test_boolean_spec(self):
     """Test generating a spec from a boolean
     """
     default = HierarchicalOrderedDict()
     default['a'] = True
     self.assert_equal_encoded_list(
         ohm_to_spec(default),
         ["a = boolean(default=True)"])
 def test_int_spec(self):
     """Test generating a spec from an integer
     """
     default = HierarchicalOrderedDict()
     default['a'] = 12
     self.assert_equal_encoded_list(
         ohm_to_spec(default),
         ["a = integer(default=12)"])
 def test_level2_spec(self):
     """Test generating a spec with two levels
     """
     default = HierarchicalOrderedDict()
     default["a.b"] = 1.2
     default["a.c.d"] = 3
     self.assert_equal_encoded_list(
         ohm_to_spec(default), ["[a]", "b = float(default=1.2)", "[[c]]", "d = integer(default=3)"]
     )
Пример #12
0
 def test_level2_spec(self):
     """Test generating a spec with two levels
     """
     default = HierarchicalOrderedDict()
     default['a.b'] = 1.2
     default['a.c.d'] = 3
     self.assert_equal_encoded_list(
         ohm_to_spec(default),
         ["[a]",
          "b = float(default=1.2)",
          "[[c]]",
          "d = integer(default=3)"])
Пример #13
0
 def test_level1_spec_unordered(self):
     """Test generating a spec with one level and wrong order
     """
     default = HierarchicalOrderedDict()
     default['a.b'] = 1.2
     default['c'] = 3.4
     default['n.k'] = 2
     default['d.a'] = 3
     default['a.a'] = 1
     self.assert_equal_encoded_list(
         ohm_to_spec(default),
         ["c = float(default=3.4)",
          "[a]",
          "a = integer(default=1)",
          "b = float(default=1.2)",
          "[d]",
          "a = integer(default=3)",
          "[n]",
          "k = integer(default=2)"])
 def test_level1_spec_unordered(self):
     """Test generating a spec with one level and wrong order
     """
     default = HierarchicalOrderedDict()
     default["a.b"] = 1.2
     default["c"] = 3.4
     default["n.k"] = 2
     default["d.a"] = 3
     default["a.a"] = 1
     self.assert_equal_encoded_list(
         ohm_to_spec(default),
         [
             "c = float(default=3.4)",
             "[a]",
             "a = integer(default=1)",
             "b = float(default=1.2)",
             "[d]",
             "a = integer(default=3)",
             "[n]",
             "k = integer(default=2)",
         ],
     )
Пример #15
0
 def test_empty_ohm(self):
     """Test converting empty ohm
     """
     ohm = HierarchicalOrderedDict()
     conf = ohm_to_spec(ohm)
     self.assertIsInstance(conf, list)
 def test_empty_ohm(self):
     """Test converting empty ohm
     """
     ohm = HierarchicalOrderedDict()
     conf = ohm_to_spec(ohm)
     self.assertIsInstance(conf, list)