def test_addtype(self): c = Company() c.name = "Company Type Test" c.vat_number = "pt123" c.code = "PT1" c.company_types = [CompanyType.Distributor,CompanyType.CSP] cs = CompanyFactory().Insert([c]) self.assertEqual(len(cs[0].company_types) , 2)
def as_new_company(self,dct): c = Company() if dct.has_key('name'): c.name = dct['name'] if dct.has_key('code'): c.code = dct['code'] if dct.has_key('vat_number'): c.vat_number = dct['vat_number'] return c
def as_company(self,dct): c = Company(dct['id']) if dct.has_key('name'): c.name = dct['name'] if dct.has_key('code'): c.code = dct['code'] if dct.has_key('vat_number'): c.vat_number = dct['vat_number'] if dct.has_key('company_types'): c.company_types = [] if(isinstance( (dct['company_types']), int )): c.company_types.append(dct['company_types']); else: for i in dct['company_types']: c.company_types.append(CompanyType.get(i)); return c
def test_companyFactory(self): #insert new company and get id c = Company() c.name = "PJC" c.vat_number = "qwe" c.code = "PJC" cs = CompanyFactory().Insert([c]) self.assertEqual(1,len(cs)) self.assertEqual("PJC",cs[0].name) #get new compnay object from id just inserted and check name id =cs[0].id cs_ii = CompanyFactory().Get([id]) self.assertEqual(1,len(cs_ii)) self.assertEqual("PJC",cs_ii[0].name) self.assertTrue(True)
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_addPerson(self): c = Company() c.name = "Person Test" c.vat_number = "pt123" c.code = "PT1" cs = CompanyFactory().Insert([c]) p = Person() p.first_name = "Brad" p.last_name = "Wiggens" p.salutation = "Mr" p.job_title = "Racer" ps = PersonFactory().Insert([p]) upc = CompanyFactory().AddPerson(cs[0],ps[0]) self.assertEqual(len(upc[0].persons) , 1)
def test_companyFactory_update(self): #insert new company and get id c = Company() c.name = "PJC" c.vat_number = "qwe" c.code = "PJC" cs = CompanyFactory().Insert([c]) self.assertEqual(1,len(cs)) self.assertEqual("PJC",cs[0].name) #update new company and get cs[0].name = "PJC UPDATE" id =cs[0].id CompanyFactory().Update([cs[0]]) #check for updates name ucs = CompanyFactory().Get([id]) self.assertEqual("PJC UPDATE",ucs[0].name)