def as_update_address(self,dct): a = Address(dct['id']) if dct.has_key('name'): a.name = dct['name'] if dct.has_key('line1'): a.line1 = dct['line1'] if dct.has_key('line2'): a.line2 = dct['line2'] if dct.has_key('line3'): a.line3 = dct['line3'] if dct.has_key('city'): a.city = dct['city'] if dct.has_key('region'): a.region = dct['region'] if dct.has_key('country'): a.country = dct['country'] if dct.has_key('postal_code'): a.postal_code = dct['postal_code'] return a
def test_addAddress(self): c = Company() c.name = "Person Test" c.vat_number = "pt123" c.code = "PT1" cs = CompanyFactory().Insert([c]) a = Address() a.name = "London" a.line1 = "1 The Road" a.city = "London" a.postal_code = "AZ1 1AZ" ps = AddressFactory().insert([a]) upc = CompanyFactory().add_address(cs[0],ps[0]) self.assertEqual(len(upc[0].addresses) , 1)
def test_addressFactory_update(self): a1 = Address() a1.line1="line1" a1.line2="line2" a1.line3="line3" a1.city="CITY" a1.region="region" a1.country="country" a2 = Address() a2.line1="2line1" a2.line2="2line2" a2.line3="2line3" a2.city="2CITY" a2.region="2region" a2.country="2country" addresses = AddressFactory().insert([a1,a2]) self.assertEqual(2,len(addresses)); addresses[1].line1="3line1" addresses[1].line2="3line2" addresses[1].line3="3line3" addresses[1].city="3CITY" addresses[1].region="3region" addresses[1].country="3country" addresses = AddressFactory().update([addresses[1]])
def test_addressFactory_inset(self): a1 = Address() a1.name = "test123" a1.line1="line1" a1.line2="line2" a1.line3="line3" a1.city="CITY" a1.region="region" a1.country="country" a1.postal_code="PC1 1AZ" a2 = Address() a2.name = "Orange" a2.line1="2line1" a2.line2="2line2" a2.line3="2line3" a2.city="2CITY" a2.region="2region" a2.country="2country" a2.postal_code = "AZ1 1AZ" addresses = AddressFactory().insert([a1,a2]) self.assertEqual(2,len(addresses));
def as_new_address(self,dct): a = Address() if dct.has_key('name'): a.name = dct['name'] return a