|
1 | 1 | import pytest |
| 2 | +from django.core.management import call_command |
2 | 3 | from django.urls import reverse |
3 | 4 | from model_mommy import mommy |
4 | 5 |
|
5 | 6 | from pythonpro.django_assertions import dj_assert_contains |
6 | | -from pythonpro.modules.models import Section, PYTHON_BIRDS |
| 7 | +from pythonpro.modules import facade |
| 8 | +from pythonpro.modules.models import Section, PYTHON_BIRDS, Module |
7 | 9 |
|
8 | 10 |
|
9 | 11 | def generate_resp(slug, client): |
10 | 12 | return client.get(reverse('modules:detail', kwargs={'slug': slug})) |
11 | 13 |
|
12 | 14 |
|
13 | 15 | @pytest.fixture |
14 | | -def client_with_user(client, django_user_model): |
| 16 | +def modules(transactional_db): |
| 17 | + call_command('loaddata', 'pythonpro_modules.json') |
| 18 | + modules = facade.get_all_modules() |
| 19 | + return modules |
| 20 | + |
| 21 | + |
| 22 | +@pytest.fixture |
| 23 | +def client_with_user(client, django_user_model, modules): |
15 | 24 | user = mommy.make(django_user_model) |
16 | 25 | client.force_login(user) |
17 | 26 | return client |
@@ -62,7 +71,7 @@ def test_page_content_with_pre_requisite(content, client_with_user): |
62 | 71 |
|
63 | 72 | @pytest.fixture |
64 | 73 | def sections(transactional_db): |
65 | | - return mommy.make(Section, 2, _module_slug=PYTHON_BIRDS.slug) |
| 74 | + return mommy.make(Section, 2, module=Module.objects.filter(slug='python-birds').get()) |
66 | 75 |
|
67 | 76 |
|
68 | 77 | @pytest.fixture |
|
0 commit comments