def test_correctly_gets_latest_url(self): test_latest = 'fixture_test_import_importpython_test_get_latest_url.txt' self._old_return_value = self.urlopen_mock.return_value self.urlopen_mock.return_value = MockResponse(read_fixture(test_latest)) latest_url = self.parser.get_latest_issue_url() self.assertEqual(latest_url, "http://importpython.com/newsletter/no/72/")
def setUp(self): self.url = 'http://us2.campaign-archive1.com/?u=e2e180baf855ac797ef407fc7&id=31658452eb&utm_content=buffera9dc3&utm_medium=social&utm_source=twitter.com&utm_campaign=buffer' test_name = 'fixture_test_import_python_weekly_test_get_blocks.txt' self.patcher = patch('digest.management.commands.import_python_weekly.urlopen') self.urlopen_mock = self.patcher.start() self.urlopen_mock.return_value = MockResponse(read_fixture(test_name))
def setUp(self): self.url = 'http://us2.campaign-archive1.com/?u=e2e180baf855ac797ef407fc7&id=31658452eb&utm_content=buffera9dc3&utm_medium=social&utm_source=twitter.com&utm_campaign=buffer' test_name = 'fixture_test_import_python_weekly_test_get_blocks.txt' self.patcher = patch( 'digest.management.commands.import_python_weekly.urlopen') self.urlopen_mock = self.patcher.start() self.urlopen_mock.return_value = MockResponse(read_fixture(test_name))
def setUp(self): self.url = "http://importpython.com/newsletter/no/60/" test_fixture = 'fixture_test_import_importpython_test_get_blocks.txt' self.patcher = patch( 'digest.management.commands.import_importpython.urlopen') self.urlopen_mock = self.patcher.start() self.urlopen_mock.return_value = MockResponse( read_fixture(test_fixture)) self.parser = ImportPythonParser()
def setUp(self): self.res_rss = AutoImportResource.objects.create(title='Test2', link='http://planetpython.org/rss20.xml', type_res='rss') self.section = Section(title='Статьи') self.section.save() test_name = 'fixture_test_import_news_test_rss.txt' self.patcher = patch('digest.management.commands.urlopen') self.urlopen_mock = self.patcher.start() self.urlopen_mock.return_value = MockResponse(read_fixture(test_name))
def setUp(self): self.res_rss = AutoImportResource.objects.create( title='Test2', link='http://planetpython.org/rss20.xml', type_res='rss') self.section = Section(title='Статьи') self.section.save() test_name = 'fixture_test_import_news_test_rss.txt' self.patcher = patch('digest.management.commands.urlopen') self.urlopen_mock = self.patcher.start() self.urlopen_mock.return_value = MockResponse(read_fixture(test_name))
def test_get_tweets(self): test_name = 'fixture_test_import_news_test_get_tweets.txt' self.patcher = patch('digest.management.commands.urlopen') self.urlopen_mock = self.patcher.start() self.urlopen_mock.return_value = MockResponse(read_fixture(test_name)) tweets = get_tweets_by_url(self.res_twitter.link) self.patcher.stop() self.assertEqual(len(tweets), 19) for x in tweets: self.assertEqual(len(x), 3) self.assertEqual(x[2], 200) self.assertEqual('http' in x[1], True) return tweets