Пример #1
0
class IContactObserverTests(TestCase):
    """
        iContact Custom Manager Tests
    """
    def setUp(self):
        settings.INSTALLED_APPS += ('icontact.tests',)
        loading.cache.loaded = False
        call_command('syncdb', verbosity=0)
        self.observer = IContactObserver()
        self.observer.observe(MyContact, MyContactAdapter())
        
    def tearDown(self):
        IContact.objects.all().delete()
        
    def test_client(self):
        self.assertIsInstance(self.observer.client(), IContactClient)
        
    def test_get_contact(self):
        contact = MyContact(email="*****@*****.**")
        contact.save()
        contact = self.observer.get_contact(contact)
        self.assertTrue(contact)
        
    def test_create(self):
        contact = MyContact(email="*****@*****.**")
        contact.save()
        local_icontacts = IContact.objects.all()
        self.assertTrue(local_icontacts)
        
    def test_update(self):
        contact = MyContact(email="*****@*****.**")
        contact.save()
        contact.first_name = 'victor'
        contact.save() #should call the update method on the observer model
        contact = self.observer.get_contact(contact)
        contact_first_name = contact['contact']['firstName']
        self.assertEqual('victor', contact_first_name)
                
    def test_delete(self):
        contact = MyContact(email="*****@*****.**")
        contact.save()
        time.sleep(10)
        icontact = self.observer.get_contact(contact)
        contact_id = icontact['contact']['contactId']
        contact.delete()
        client = self.observer.client()
        contact = client.get_contact(contact_id)
        self.assertEqual('deleted', contact['contact']['status'])
Пример #2
0
 def setUp(self):
     settings.INSTALLED_APPS += ('icontact.tests',)
     loading.cache.loaded = False
     call_command('syncdb', verbosity=0)
     self.observer = IContactObserver()
     self.observer.observe(MyContact, MyContactAdapter())