def test_should_save_a_contact_belonging_to_a_category(self): category = Category(name="friend") category.save() self.assertEqual(1, len(Category.objects.filter())) contact = Contact() contact.name = "ben" contact.email_address = "brainychip.gmail.com" contact.category = category contact.save() self.assertEqual(contact.category, category)
def readData(self, filePath): data = csv.DictReader(open(filePath , encoding='utf-8')) count = 0 print('reading: %s' % filePath) for row in data: count += 1 sys.stdout.write('.') sys.stdout.flush() contact = Contact() contact.given_name = row['GivenName'] contact.surname = row['Surname'] contact.street_address = row['StreetAddress'] contact.city = row['City'] contact.zip_code = row['ZipCode'] contact.country = row['Country'] contact.email_address = row['EmailAddress'] contact.telephone_number = row['TelephoneNumber'] contact.save() print('\nready: %d contacts read' % count)
def test_should_save_partial_contact(self): contact = Contact() contact.name = "ben" contact.email_address = "brainychip.gmail.com" contact.save() self.assertEqual(Contact.objects.count(), 1)