Esempio n. 1
0
 def test_translate_struct_tuple(self):
     """Tests if tuple gets properly converted to NaElements."""
     root = NaElement('root')
     child = ('e1', 'e2')
     root.translate_struct(child)
     self.assertEqual(len(root.get_children()), 2)
     self.assertIsNone(root.get_child_content('e1'))
     self.assertIsNone(root.get_child_content('e2'))
Esempio n. 2
0
 def test_translate_struct_tuple(self):
     """Tests if tuple gets properly converted to NaElements."""
     root = NaElement('root')
     child = ('e1', 'e2')
     root.translate_struct(child)
     self.assertEqual(len(root.get_children()), 2)
     self.assertIsNone(root.get_child_content('e1'))
     self.assertIsNone(root.get_child_content('e2'))
Esempio n. 3
0
 def test_translate_struct_dict_unique_key(self):
     """Tests if dict gets properly converted to NaElements."""
     root = NaElement('root')
     child = {'e1': 'v1', 'e2': 'v2', 'e3': 'v3'}
     root.translate_struct(child)
     self.assertEqual(len(root.get_children()), 3)
     self.assertEqual(root.get_child_content('e1'), 'v1')
     self.assertEqual(root.get_child_content('e2'), 'v2')
     self.assertEqual(root.get_child_content('e3'), 'v3')
Esempio n. 4
0
 def test_translate_struct_dict_unique_key(self):
     """Tests if dict gets properly converted to NaElements."""
     root = NaElement('root')
     child = {'e1': 'v1', 'e2': 'v2', 'e3': 'v3'}
     root.translate_struct(child)
     self.assertEqual(len(root.get_children()), 3)
     self.assertEqual(root.get_child_content('e1'), 'v1')
     self.assertEqual(root.get_child_content('e2'), 'v2')
     self.assertEqual(root.get_child_content('e3'), 'v3')
Esempio n. 5
0
 def test_translate_struct_dict_nonunique_key(self):
     """Tests if list/dict gets properly converted to NaElements."""
     root = NaElement('root')
     child = [{'e1': 'v1', 'e2': 'v2'}, {'e1': 'v3'}]
     root.translate_struct(child)
     self.assertEqual(len(root.get_children()), 3)
     children = root.get_children()
     for c in children:
         if c.get_name() == 'e1':
             self.assertIn(c.get_content(), ['v1', 'v3'])
         else:
             self.assertEqual(c.get_content(), 'v2')
Esempio n. 6
0
 def test_translate_struct_dict_nonunique_key(self):
     """Tests if list/dict gets properly converted to NaElements."""
     root = NaElement('root')
     child = [{'e1': 'v1', 'e2': 'v2'}, {'e1': 'v3'}]
     root.translate_struct(child)
     self.assertEqual(len(root.get_children()), 3)
     children = root.get_children()
     for c in children:
         if c.get_name() == 'e1':
             self.assertIn(c.get_content(), ['v1', 'v3'])
         else:
             self.assertEqual(c.get_content(), 'v2')