Exemple #1
0
 def test_convert_none_content_object_to_dict_and_back(self):
     """Test for original dictionary equivalent to yielded one
     using py2dict, then dict2py, then finally back to py2dict
     on a None content.
     """
     field = PYUNTL_DISPATCH['title'](
         content=None
     )
     self.record.add_child(field)
     self.record.children[0].set_qualifier('officialtitle')
     missing_content_dict = py2dict(self.record)
     self.assertTrue(missing_content_dict == {'title': []})
     py_from_dict = untldict2py(missing_content_dict)
     self.assertTrue(
         self.record.children[0].qualifier != py_from_dict.qualifier
     )
     self.record.children[0].content = 'fake content'
     missing_content_dict = py2dict(self.record)
     self.assertTrue(
         missing_content_dict == {
             'title': [
                 {'content': 'fake content', 'qualifier': 'officialtitle'}
             ]
         }
     )
Exemple #2
0
 def test_convert_none_content_object_to_dict_and_back(self):
     """Test for original dictionary equivalent to yielded one
     using py2dict, then dict2py, then finally back to py2dict
     on a None content.
     """
     field = PYUNTL_DISPATCH['title'](
         content=None
     )
     self.record.add_child(field)
     self.record.children[0].set_qualifier('officialtitle')
     missing_content_dict = py2dict(self.record)
     self.assertTrue(missing_content_dict == {'title': []})
     py_from_dict = untldict2py(missing_content_dict)
     self.assertTrue(
         self.record.children[0].qualifier != py_from_dict.qualifier
     )
     self.record.children[0].content = 'fake content'
     missing_content_dict = py2dict(self.record)
     self.assertTrue(
         missing_content_dict == {
             'title': [
                 {'content': 'fake content', 'qualifier': 'officialtitle'}
             ]
         }
     )
Exemple #3
0
 def test_create_element_dict(self):
     field = PYUNTL_DISPATCH['title'](content='fake title')
     self.record.add_child(field)
     field = PYUNTL_DISPATCH['meta'](content=None)
     self.record.add_child(field)
     d1 = py2dict(self.record)
     d2 = {'meta': [], 'title': [{'content': 'fake title'}]}
     self.assertTrue(d1 == d2)
Exemple #4
0
 def test_create_element_dict(self):
     field = PYUNTL_DISPATCH['title'](content='fake title')
     self.record.add_child(field)
     field = PYUNTL_DISPATCH['meta'](content=None)
     self.record.add_child(field)
     d1 = py2dict(self.record)
     d2 = {'meta': [], 'title': [{'content': 'fake title'}]}
     self.assertTrue(d1 == d2)
Exemple #5
0
 def test_convert_content_no_qualifier_roundtrip(self):
     """Test adding a child without a qualifier doesn't create one
     when converting from py to dict to py.
     """
     field = PYUNTL_DISPATCH['title'](
         content='Tie Till the Title'
     )
     self.record.add_child(field)
     content_dict = py2dict(self.record)
     self.assertTrue(
         content_dict == {'title': [{'content': 'Tie Till the Title'}]}
     )
     py_from_dict = untldict2py(content_dict)
     self.assertTrue(
         py_from_dict.children[0].qualifier is None
     )
Exemple #6
0
 def test_convert_content_no_qualifier_roundtrip(self):
     """Test adding a child without a qualifier doesn't create one
     when converting from py to dict to py.
     """
     field = PYUNTL_DISPATCH['title'](
         content='Tie Till the Title'
     )
     self.record.add_child(field)
     content_dict = py2dict(self.record)
     self.assertTrue(
         content_dict == {'title': [{'content': 'Tie Till the Title'}]}
     )
     py_from_dict = untldict2py(content_dict)
     self.assertTrue(
         py_from_dict.children[0].qualifier is None
     )
Exemple #7
0
 def testCircularEquality(self):
     self.assertEqual(
         py2dict(untlxml2py(BytesIO(
                 pydict2xmlstring(UNTL_DICT)))), UNTL_DICT)
Exemple #8
0
 def testCircularEquality(self):
     self.assertEqual(
         py2dict(untlxml2py(StringIO.StringIO(
                 pydict2xmlstring(UNTL_DICT)))), UNTL_DICT)