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')
    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)
 def test_task_successfull(self, _):
     """Do nothing when all is a-ok"""
     tasks.rescrape_urls(['http://something-test/'])