Esempio n. 1
0
 def test_add_counter_empty_namedset(self):
     elem = {}
     spec = [{
         'item_name': 'dirs',
         'item_type': 'named_set',
         'named_set_item_spec': {
             'item_name':
             'dir',
             'item_type':
             'map',
             'map_item_spec': [{
                 'item_name': 'counter1',
                 'item_type': 'integer',
                 'item_default': 0
             }, {
                 'item_name': 'counter2',
                 'item_type': 'integer',
                 'item_default': 0
             }]
         }
     }]
     self.assertEqual(\
         counters._add_counter(elem, spec, 'dirs/foo/counter1'), 0)
     self.assertEqual(\
         counters._add_counter(elem, spec, 'dirs/bar/counter2'), 0)
Esempio n. 2
0
 def test_add_counter_empty(self):
     self.assertEqual(\
         counters._add_counter(
             {},
             [ { 'item_name' : 'counter',
                 'item_type' : 'integer',
                 'item_default' : 0 } ],
             'counter'), 0)
Esempio n. 3
0
 def test_add_counter_empty_namedset(self):
     elem = {}
     spec = [
         {
             "item_name": "dirs",
             "item_type": "named_set",
             "named_set_item_spec": {
                 "item_name": "dir",
                 "item_type": "map",
                 "map_item_spec": [
                     {"item_name": "counter1", "item_type": "integer", "item_default": 0},
                     {"item_name": "counter2", "item_type": "integer", "item_default": 0},
                 ],
             },
         }
     ]
     self.assertEqual(counters._add_counter(elem, spec, "dirs/foo/counter1"), 0)
     self.assertEqual(counters._add_counter(elem, spec, "dirs/bar/counter2"), 0)
Esempio n. 4
0
 def test_add_counter_empty(self):
     self.assertEqual(
         counters._add_counter({}, [{"item_name": "counter", "item_type": "integer", "item_default": 0}], "counter"),
         0,
     )
Esempio n. 5
0
 def test_add_counter_normal(self):
     element = {"counter": 1}
     self.assertEqual(counters._add_counter(element, [], "counter"), 1)
Esempio n. 6
0
 def test_add_counter_normal(self):
     element = {'counter': 1}
     self.assertEqual(\
         counters._add_counter(element, [], 'counter'), 1)