|
6 | 6 | from django.conf import settings |
7 | 7 | from django.core import serializers |
8 | 8 | from django.core.management import call_command |
9 | | -from django.core.exceptions import ImproperlyConfigured |
10 | 9 |
|
11 | 10 | import responses |
12 | 11 |
|
13 | 12 | from pages.models import Image |
14 | 13 |
|
15 | | -from . import FAKE_PEP_REPO |
| 14 | +from . import FAKE_PEP_ARTIFACT |
16 | 15 |
|
17 | 16 |
|
18 | | -@responses.activate |
| 17 | +PEP_ARTIFACT_URL = 'https://example.net/fake-peps.tar.gz' |
| 18 | + |
| 19 | + |
| 20 | +@override_settings(PEP_ARTIFACT_URL=PEP_ARTIFACT_URL) |
19 | 21 | class PEPManagementCommandTests(TestCase): |
20 | 22 |
|
21 | 23 | def setUp(self): |
22 | | - self.peps_tar = io.open(FAKE_PEP_ARTIFACT, 'rb') |
23 | 24 | responses.add( |
24 | 25 | responses.GET, |
25 | | - 'https://example.net/fake-peps.tar.gz', |
| 26 | + PEP_ARTIFACT_URL, |
26 | 27 | headers={'Last-Modified': 'Sun, 24 Feb 2019 18:01:42 GMT'}, |
27 | 28 | stream=True, |
28 | 29 | content_type='application/x-tar', |
29 | 30 | status=200, |
30 | | - body=self.peps_tar, |
| 31 | + body=open(FAKE_PEP_ARTIFACT, 'rb'), |
31 | 32 | ) |
32 | 33 |
|
33 | | - @override_settings(PEP_ARTIFACT_URL='https://example.net/fake-peps.tar.gz') |
| 34 | + @responses.activate |
34 | 35 | def test_generate_pep_pages_real(self): |
35 | 36 | call_command('generate_pep_pages') |
36 | 37 |
|
37 | | - @override_settings(PEP_ARTIFACT_URL='https://example.net/fake-peps.tar.gz') |
| 38 | + @responses.activate |
38 | 39 | def test_image_generated(self): |
39 | 40 | call_command('generate_pep_pages') |
40 | 41 | img = Image.objects.get(page__path='dev/peps/pep-3001/') |
41 | 42 | soup = BeautifulSoup(img.page.content.raw, 'lxml') |
42 | 43 | self.assertIn(settings.MEDIA_URL, soup.find('img')['src']) |
43 | 44 |
|
44 | | - @override_settings(PEP_ARTIFACT_URL='https://example.net/fake-peps.tar.gz') |
| 45 | + @responses.activate |
45 | 46 | def test_dump_pep_pages(self): |
46 | 47 | call_command('generate_pep_pages') |
47 | 48 | stdout = io.StringIO() |
|
0 commit comments