def test_web_import(self): "Assert that the web client can POST a username and password and get back the list of contacts" try: with mock.patch( "contactstore.openinviter.get_contacts") as mock_importer: mock_importer.return_value = self.data_list self.assertTrue( self.client.login(username=self.importing.username, password=IMPORTER_PASSWORD)) import_url = url_reverse( 'contactstore.views.download_contacts') response = self.client.post(import_url, { "email": self.importing.email, "password": IMPORTER_PASSWORD }) self.assertEquals(200, response.status_code) # Check we have all the users xpath = "//ul[@class='friends']//li[text()='%s']" assertXpath(response.content, xpath % (self.email1), html=True) assertXpath(response.content, xpath % (self.email2), html=True) assertXpath(response.content, xpath % (self.email3), html=True) finally: pass
def test_web_import(self): "Assert that the web client can POST a username and password and get back the list of contacts" try: with mock.patch("contactstore.openinviter.get_contacts") as mock_importer: mock_importer.return_value = self.data_list self.assertTrue(self.client.login( username=self.importing.username, password=IMPORTER_PASSWORD )) import_url = url_reverse('contactstore.views.download_contacts') response = self.client.post(import_url, { "email": self.importing.email, "password": IMPORTER_PASSWORD }) self.assertEquals(200, response.status_code) # Check we have all the users xpath = "//ul[@class='friends']//li[text()='%s']" assertXpath( response.content, xpath % (self.email1), html=True ) assertXpath( response.content, xpath % (self.email2), html=True ) assertXpath( response.content, xpath % (self.email3), html=True ) finally: pass
def test_get_list(self): c = Client() response = c.get("/e/") self.assert_(response.status_code == 200) assertXpath(response.content, "//ul//li", html=True)