33from model_mommy import mommy
44
55from pythonpro .django_assertions import dj_assert_contains
6- from pythonpro .modules .models import Section , Module , Chapter
6+ from pythonpro .modules .models import Chapter , Module , Section
77
88
99@pytest .fixture
@@ -27,10 +27,13 @@ def chapters(section):
2727
2828
2929@pytest .fixture
30- def resp_section (client , django_user_model , section , chapters ):
30+ def resp_section (client , django_user_model , section : Section , chapters ):
3131 user = mommy .make (django_user_model )
3232 client .force_login (user )
33- return client .get (reverse ('sections:detail' , kwargs = {'slug' : section .slug }))
33+ return client .get (reverse (
34+ 'modules:section_detail' ,
35+ kwargs = {'section_slug' : section .slug , 'module_slug' : section .module_slug ()}),
36+ secure = True )
3437
3538
3639def test_chapter_title_on_section (resp_section , chapters ):
@@ -44,10 +47,27 @@ def test_chapter_url_on_section(resp_section, chapters):
4447
4548
4649@pytest .fixture
47- def resp (client , chapter , django_user_model ):
50+ def resp_old_path (client_with_lead , chapter , django_user_model ):
51+ return client_with_lead .get (
52+ reverse ('chapters:detail_old' , kwargs = {'chapter_slug' : chapter .slug }), secure = True )
53+
54+
55+ def test_redirect_status_code (resp_old_path ):
56+ assert resp_old_path .status_code == 301
57+
58+
59+ def test_redirect_url (resp_old_path , chapter ):
60+ assert resp_old_path .url == chapter .get_absolute_url ()
61+
62+
63+ @pytest .fixture
64+ def resp (client , chapter : Chapter , django_user_model ):
4865 user = mommy .make (django_user_model )
4966 client .force_login (user )
50- return client .get (reverse ('chapters:detail' , kwargs = {'slug' : chapter .slug }))
67+ return client .get (reverse (
68+ 'modules:chapter_detail' ,
69+ kwargs = {'chapter_slug' : chapter .slug , 'module_slug' : chapter .module_slug ()}),
70+ secure = True )
5171
5272
5373def test_status_code (resp ):
0 commit comments