Beispiel #1
0
    def test_good_call(self):
        self.mocked_fetch_all.side_effect = None

        fetch_translation(self.fp.id, 'en-US')
        fp = FeaturePage.objects.get(id=self.fp.id)
        self.assertEqual(fp.STATUS_PAGES, fp.status)
        trans = fp.translatedcontent_set.get(locale='en-US')
        self.assertEqual(trans.STATUS_FETCHED, trans.status)
        self.mocked_fetch_all.assert_called_once_with(self.fp.id)
    def test_good_call(self):
        self.mocked_fetch_all.side_effect = None

        fetch_translation(self.fp.id, "en-US")
        fp = FeaturePage.objects.get(id=self.fp.id)
        self.assertEqual(fp.STATUS_PAGES, fp.status)
        trans = fp.translatedcontent_set.get(locale="en-US")
        self.assertEqual(trans.STATUS_FETCHED, trans.status)
        self.mocked_fetch_all.assertCalledOnce(self.fp.id)
Beispiel #3
0
    def test_parsed(self):
        self.fp.status = self.fp.STATUS_PARSING
        self.fp.save()
        t = self.fp.translatedcontent_set.get(locale='en-US')
        t.status = t.STATUS_FETCHED
        t.save()

        fetch_translation(self.fp.id, 'en-US')
        fp = FeaturePage.objects.get(id=self.fp.id)
        self.assertEqual(fp.STATUS_PARSING, fp.status)
        trans = fp.translatedcontent_set.get(locale='en-US')
        self.assertEqual(trans.STATUS_FETCHED, trans.status)
    def test_parsed(self):
        self.fp.status = self.fp.STATUS_PARSING
        self.fp.save()
        t = self.fp.translatedcontent_set.get(locale="en-US")
        t.status = t.STATUS_FETCHED
        t.save()

        fetch_translation(self.fp.id, "en-US")
        fp = FeaturePage.objects.get(id=self.fp.id)
        self.assertEqual(fp.STATUS_PARSING, fp.status)
        trans = fp.translatedcontent_set.get(locale="en-US")
        self.assertEqual(trans.STATUS_FETCHED, trans.status)
    def test_not_found(self):
        self.response.status_code = 404
        content = "Not Found"
        self.response.text = content
        self.response.raise_for_status.side_effect = Exception("Not Called")
        self.mocked_fetch_all.side_effect = None

        fetch_translation(self.fp.id, "es")
        fp = FeaturePage.objects.get(id=self.fp.id)
        self.assertEqual(fp.STATUS_PAGES, fp.status)
        trans = fp.translatedcontent_set.get(locale="es")
        self.assertEqual(trans.STATUS_ERROR, trans.status)
        self.assertEqual(content, trans.raw)
        url = trans.url() + "?raw"
        issue = [["failed_download", 0, 0, {"url": url, "status": 404, "content": content}, None]]
        self.assertEqual(issue, fp.data["meta"]["scrape"]["issues"])
Beispiel #6
0
    def test_not_found(self):
        self.response.status_code = 404
        content = 'Not Found'
        self.response.text = content
        self.response.raise_for_status.side_effect = Exception('Not Called')
        self.mocked_fetch_all.side_effect = None

        fetch_translation(self.fp.id, 'es')
        fp = FeaturePage.objects.get(id=self.fp.id)
        self.assertEqual(fp.STATUS_PAGES, fp.status)
        trans = fp.translatedcontent_set.get(locale='es')
        self.assertEqual(trans.STATUS_ERROR, trans.status)
        self.assertEqual(content, trans.raw)
        url = trans.url() + '?raw'
        issue = [[
            'failed_download', 0, 0,
            {'url': url, 'status': 404, 'content': content}, None]]
        self.assertEqual(issue, fp.data['meta']['scrape']['issues'])
Beispiel #7
0
    def test_not_found(self):
        self.response.status_code = 404
        content = 'Not Found'
        self.response.text = content
        self.response.raise_for_status.side_effect = Exception('Not Called')
        self.mocked_fetch_all.side_effect = None

        fetch_translation(self.fp.id, 'es')
        fp = FeaturePage.objects.get(id=self.fp.id)
        self.assertEqual(fp.STATUS_PAGES, fp.status)
        trans = fp.translatedcontent_set.get(locale='es')
        self.assertEqual(trans.STATUS_ERROR, trans.status)
        self.assertEqual(content, trans.raw)
        url = trans.url() + '?raw'
        issue = [[
            'failed_download', 0, 0, {
                'url': url,
                'status': 404,
                'content': content
            }, None
        ]]
        self.assertEqual(issue, fp.data['meta']['scrape']['issues'])