Example #1
0
 def test_populate_services(self):
     data = {
         u'services': {
             u'datanode': {
                 u'dfs.blocksize': 134217728,
                 u'name': u'datanode',
                 u'nodes': [u'slave0', u'slave1', u'slave2'],
                 u'status': u'pending'
             },
             u'yarn': {
                 u'name': u'yarn',
                 u'nodes': [u'master0'],
                 u'status': u'running',
                 u'yarn.scheduler.minimum-allocation-vcores': 1
             }
         }
     }
     result = {}
     registry._populate(result, using=data, prefix='X')
     expected = {
         'X/services/datanode/dfs.blocksize': 134217728,
         'X/services/datanode/name': 'datanode',
         'X/services/datanode/nodes/slave0': '',
         'X/services/datanode/nodes/slave1': '',
         'X/services/datanode/nodes/slave2': '',
         'X/services/datanode/status': 'pending',
         'X/services/yarn/name': 'yarn',
         'X/services/yarn/nodes/master0': '',
         'X/services/yarn/status': 'running',
         'X/services/yarn/yarn.scheduler.minimum-allocation-vcores': 1,
     }
     self.assertEqual(result, expected)
 def test_populate_services(self):
     data = {u'services': {
                 u'datanode': {
                     u'dfs.blocksize': 134217728,
                     u'name': u'datanode',
                     u'nodes': [
                         u'slave0',
                         u'slave1',
                         u'slave2'],
                     u'status': u'pending'},
                 u'yarn': {
                     u'name': u'yarn',
                     u'nodes': [u'master0'],
                     u'status': u'running',
                     u'yarn.scheduler.minimum-allocation-vcores': 1}}}
     result = {}
     registry._populate(result, using=data, prefix='X')
     expected = {
         'X/services/datanode/dfs.blocksize': 134217728,
         'X/services/datanode/name': 'datanode',
         'X/services/datanode/nodes/slave0': '',
         'X/services/datanode/nodes/slave1': '',
         'X/services/datanode/nodes/slave2': '',
         'X/services/datanode/status': 'pending',
         'X/services/yarn/name': 'yarn',
         'X/services/yarn/nodes/master0': '',
         'X/services/yarn/status': 'running',
         'X/services/yarn/yarn.scheduler.minimum-allocation-vcores': 1,
     }
     self.assertEqual(result, expected)
Example #3
0
 def test_populate_nested_dict_and_list(self):
     data = {
         'a': 1,
         'b': 'hello',
         'dict': {
             'c': 1,
             'd': {
                 'e': 1,
                 'f': 2,
                 'g': {
                     'h': '_',
                     'j': 2
                 },
                 'list': ['a', 'b']
             }
         },
     }
     result = {}
     registry._populate(result, using=data, prefix='X')
     expected = {
         'X/a': 1,
         'X/b': 'hello',
         'X/dict/c': 1,
         'X/dict/d/e': 1,
         'X/dict/d/f': 2,
         'X/dict/d/g/h': '_',
         'X/dict/d/g/j': 2,
         'X/dict/d/list/a': '',
         'X/dict/d/list/b': '',
     }
     self.assertEqual(result, expected)
 def test_populate_nested_dict_and_list(self):
     data = {
         'a': 1,
         'b': 'hello',
         'dict': {
             'c': 1,
             'd': {
                 'e': 1,
                 'f': 2,
                 'g': {
                     'h': '_',
                     'j': 2
                 },
                 'list': ['a', 'b']
             }
         },
     }
     result = {}
     registry._populate(result, using=data, prefix='X')
     expected = {
         'X/a': 1,
         'X/b': 'hello',
         'X/dict/c': 1,
         'X/dict/d/e': 1,
         'X/dict/d/f': 2,
         'X/dict/d/g/h': '_',
         'X/dict/d/g/j': 2,
         'X/dict/d/list/a': '',
         'X/dict/d/list/b': '',
     }
     self.assertEqual(result, expected)
Example #5
0
 def test_populate_simple(self):
     data = {'a': 1, 'b': 'hello'}
     result = {}
     registry._populate(result, using=data, prefix='X')
     expected = {
         'X/a': 1,
         'X/b': 'hello',
     }
     self.assertEqual(result, expected)
 def test_populate_simple(self):
     data = {'a': 1, 'b': 'hello'}
     result = {}
     registry._populate(result, using=data, prefix='X')
     expected = {
         'X/a': 1,
         'X/b': 'hello',
     }
     self.assertEqual(result, expected)
Example #7
0
 def test_populate_simple_list(self):
     data = {'list': [1, 2, 3]}
     result = {}
     registry._populate(result, using=data, prefix='X')
     expected = {
         'X/list/1': '',
         'X/list/2': '',
         'X/list/3': '',
     }
     self.assertEqual(result, expected)
 def test_populate_simple_dict(self):
     data = {
         'dict': {'n1': 'n.n1', 'n2': 'n.n2'},
     }
     result = {}
     registry._populate(result, using=data, prefix='X')
     expected = {
         'X/dict/n1': 'n.n1',
         'X/dict/n2': 'n.n2',
     }
     self.assertEqual(result, expected)
 def test_populate_simple_list(self):
     data = {
         'list': [1, 2, 3]
     }
     result = {}
     registry._populate(result, using=data, prefix='X')
     expected = {
         'X/list/1': '',
         'X/list/2': '',
         'X/list/3': '',
     }
     self.assertEqual(result, expected)
Example #10
0
 def test_populate_simple_dict(self):
     data = {
         'dict': {
             'n1': 'n.n1',
             'n2': 'n.n2'
         },
     }
     result = {}
     registry._populate(result, using=data, prefix='X')
     expected = {
         'X/dict/n1': 'n.n1',
         'X/dict/n2': 'n.n2',
     }
     self.assertEqual(result, expected)
 def test_populate_list_and_dict(self):
     data = {
         'a': 1,
         'b': 'hello',
         'dict': {'n1': 'n.n1', 'n2': 'n.n2'},
         'list': [1, 2, 3]
     }
     result = {}
     registry._populate(result, using=data, prefix='X')
     expected = {
         'X/a': 1,
         'X/b': 'hello',
         'X/dict/n1': 'n.n1',
         'X/dict/n2': 'n.n2',
         'X/list/1': '',
         'X/list/2': '',
         'X/list/3': '',
     }
     self.assertEqual(result, expected)
Example #12
0
 def test_populate_list_and_dict(self):
     data = {
         'a': 1,
         'b': 'hello',
         'dict': {
             'n1': 'n.n1',
             'n2': 'n.n2'
         },
         'list': [1, 2, 3]
     }
     result = {}
     registry._populate(result, using=data, prefix='X')
     expected = {
         'X/a': 1,
         'X/b': 'hello',
         'X/dict/n1': 'n.n1',
         'X/dict/n2': 'n.n2',
         'X/list/1': '',
         'X/list/2': '',
         'X/list/3': '',
     }
     self.assertEqual(result, expected)