Пример #1
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')
Пример #2
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')
Пример #3
0
 def test_setter_builtin_types(self):
     """Tests str, int, float get converted to NaElement."""
     root = NaElement('root')
     root['e1'] = 'v1'
     root['e2'] = 1
     root['e3'] = 2.0
     root['e4'] = 8l
     self.assertEqual(len(root.get_children()), 4)
     self.assertEqual(root.get_child_content('e1'), 'v1')
     self.assertEqual(root.get_child_content('e2'), '1')
     self.assertEqual(root.get_child_content('e3'), '2.0')
     self.assertEqual(root.get_child_content('e4'), '8')
Пример #4
0
 def test_setter_builtin_types(self):
     """Tests str, int, float get converted to NaElement."""
     root = NaElement('root')
     root['e1'] = 'v1'
     root['e2'] = 1
     root['e3'] = 2.0
     root['e4'] = 8l
     self.assertEqual(len(root.get_children()), 4)
     self.assertEqual(root.get_child_content('e1'), 'v1')
     self.assertEqual(root.get_child_content('e2'), '1')
     self.assertEqual(root.get_child_content('e3'), '2.0')
     self.assertEqual(root.get_child_content('e4'), '8')
Пример #5
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'))
Пример #6
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'))
Пример #7
0
 def test_setter_no_value(self):
     """Tests key with None value."""
     root = NaElement('root')
     root['k'] = None
     self.assertIsNone(root.get_child_content('k'))
Пример #8
0
 def test_setter_no_value(self):
     """Tests key with None value."""
     root = NaElement('root')
     root['k'] = None
     self.assertIsNone(root.get_child_content('k'))