Example #1
0
 def test_all_kinds_of_fields_serialization_to_xml(self):
     dtime = datetime.now()
     xml = '''
         <Person>
           <cellphone>(21) 9988-7766</cellphone>
           <name>John Doe</name>
           <weight>74.35</weight>
           <married>False</married>
           <creation_date>%s</creation_date>
           <blog>http://blog.john.doe.net</blog>
           <email>[email protected]</email>
           <id>1</id>
           <biography>blabla</biography>
           <childrens>2</childrens>
         </Person>
     ''' % dtime.strftime("%Y-%m-%d %H:%M:%S")
     john = self.Person(id=1,
                        name=u'John Doe',
                        creation_date=dtime,
                        email=u"*****@*****.**",
                        weight=74.349999999999994,
                        married=False,
                        childrens=2,
                        cellphone=u"(21) 9988-7766",
                        biography=u"blabla",
                        blog=u"http://blog.john.doe.net")
     self.assertEquals(one_line_xml(john.serialize(to='xml')), one_line_xml(xml))
 def test_to_xml_evaluated(self):
     polly = Parrot(id=1,
                    name=u"Polly",
                    is_dead=True,
                    cage=Cage(id=1, color=u'black'))
     self.assertEquals(one_line_xml(polly.serialize(to='xml')),
                       one_line_xml(self.evaluated_xml))
Example #3
0
    def test_modelset_serialization_xml(self):
        john = self.Person(first_name=u'John Doe',
                      birthdate=date(1988, 2, 10))
        mary = self.Person(first_name=u'Mary Doe',
                      birthdate=date(1989, 10, 20))
        PersonSet = self.Person.Set()
        people = PersonSet(john, mary)

        self.assertEquals(one_line_xml(people.serialize(to='xml')),
                          one_line_xml(self.my_xml))
 def test_serialization_missing(self):
     xserial = XMLSerializer(self.missing_dict)
     xml = one_line_xml(self.missing_xml)
     self.assertEquals(one_line_xml(xserial.serialize()), xml)
Example #5
0
 def test_model_deserialization_extra_json(self):
     john = self.Person.deserialize(self.extra_json, format='json')
     self.assertEquals(one_line_xml(john.serialize(to='xml')),
                       one_line_xml(self.my_xml))
Example #6
0
    def test_model_serialization_xml(self):
        john = self.Person(first_name=u'John Doe',
                           birthdate=date(1988, 2, 10))

        self.assertEquals(john.serialize(to='xml'),
                          one_line_xml(self.my_xml))