예제 #1
0
 def test_creating_new_contact_and_saving_it_to_the_database(self):
     # Test creating a new event object.
     user = User.objects.create(username="******")
     country = Country.objects.create(name ='Nowhere')
     region = Region.objects.create(region_name="How cares", country=country)
     city = City.objects.create(city_name='WonderLand', country=country, region_name=region)
     contact = Contact()
     contact.user = user
     contact.fr_name = "John"
     contact.ls_name = "Doe"
     contact.m_name = ""
     contact.email = ""
     contact.overview = ""
     contact.photo_profile = ""
     contact.phone = ""
     contact.country = country
     contact.city = city
     contact.degrees = ""
     contact.lt_contact = ""
     contact.tags = ""
     contact.company = None
     contact.latech_contact = ""
     contact.financial_organization = ""
     contact.government_organization = ""
     contact.title = ""
     contact.industry = ""
     contact.technology = ""
     contact.application = ""
     # Testing __unicode__ method
     self.assertEquals(unicode(contact.fr_name +" "+contact.ls_name), 'John Doe')
예제 #2
0
 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)