Пример #1
0
    def test_process_available_links_failed(self, mock_response):
        mock_response.side_effect = mock.Mock(
            side_effect=Exception('Error'))  # noqa
        process_available_links(1)

        website_db = Website.query.filter(Website.id == 1).first()  # noqa
        self.assertEqual(Website.query.count(), 1)
        self.assertEqual(website_db.status.value, 'ERROR')
        self.assertEqual(website_db.status_desc, 'Error')  # noqa
        self.assertEqual(mock_response.call_count, 1)
Пример #2
0
    def test_process_available_links(self, mock_save_website):
        self.assertEqual(Website.query.count(), 1)
        with vcr.use_cassette(
                'tests/fixtures/cassettes/test_process_available_links.yaml'
        ):  # noqa
            process_available_links(1)

        website_db = Website.query.filter(Website.id == 1).first()  # noqa

        self.assertEqual(website_db.status.value, "DONE")
Пример #3
0
    def test_process_available_links_sqlalchemy_error(self, mock_response):
        mock_response.side_effect = mock.Mock(side_effect=SQLAlchemyError())
        with self.assertRaises(SQLAlchemyError):
            process_available_links(1)

        self.assertEqual(mock_response.call_count, 1)
Пример #4
0
    def test_process_available_links_connect_timeout(self, mock_response):
        mock_response.side_effect = mock.Mock(side_effect=ConnectTimeout())
        with self.assertRaises(ConnectTimeout):
            process_available_links(1)

        self.assertEqual(mock_response.call_count, 1)
Пример #5
0
    def test_process_available_links_web_site_not_found(self):
        with self.assertRaises(TasksException) as error:
            process_available_links(2)

        self.assertEqual(str(error.exception),
                         "Website not found: website_id=2")  # noqa