예제 #1
0
    def test_task_unsuccessfull_invalid_url(self, _):
        url = 'invalid-url'
        with LogCapture() as l:
            tasks.rescrape_urls([url, ])

            correct_message = False
            for record in l.records:
                if (record.msg == ('Failed to tell Facebook to rescrape '
                                   'URL "%s"')):
                    correct_message = True
            self.assertTrue(correct_message, 'Error message not logged')
예제 #2
0
    def test_task_unsuccessfull_facebook_response_other_than_ok(self, _):
        url = 'http://something-else.sg/'
        json = {'something': 'fluffy'}

        with patch('requests.post', return_value=FakeResponse(404, json)):
            with LogCapture() as l:
                tasks.rescrape_urls([url, ])

                for record in l.records:
                    if (record.msg == ('Failed to tell Facebook to rescrape '
                                       'URL "{0}"'.format(url))):
                        self.assertEqual(record.facebook_response, json)
예제 #3
0
 def test_task_successfull(self, _):
     """Do nothing when all is a-ok"""
     tasks.rescrape_urls(['http://something-test/'])