File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ """Using as facade for the entire app"""
2+
3+ from pythonpro .modules .models .modules import (
4+ ALL as ALL_MODULES ,
5+ PYTHONIC_OBJECTS ,
6+ PYTHON_BIRDS ,
7+ PYTOOLS ,
8+ PYTHON_FOR_PYTHONISTS ,
9+ PYTHON_PATTERNS , PYTHON_WEB ,
10+ TECH_INTERVIEW
11+ )
12+
13+ ALL_MODULES
14+ PYTHON_BIRDS
15+ PYTHONIC_OBJECTS
16+ PYTOOLS
17+ PYTHON_FOR_PYTHONISTS
18+ PYTHON_PATTERNS
19+ PYTHON_WEB
20+ TECH_INTERVIEW
Original file line number Diff line number Diff line change 11from django .db import models
22
3- # Create your models here.
3+
4+ class Section (models .Model ):
5+ title = models .CharField (max_length = 50 )
6+ description = models .TextField ()
7+ slug = models .SlugField (unique = True )
8+ _module_slug = models .SlugField ()
Original file line number Diff line number Diff line change 22from django .urls import reverse
33from model_mommy import mommy
44
5+ from pythonpro .django_assertions import dj_assert_contains
6+ from pythonpro .modules import PYTHON_BIRDS
7+ from pythonpro .sections .models import Section
8+
9+
10+ @pytest .fixture
11+ def section ():
12+ return mommy .make (Section , slug = 'procedural' , _module_slug = PYTHON_BIRDS .slug )
13+
514
615@pytest .fixture
7- def resp (client , django_user_model ):
16+ def resp (client , django_user_model , section ):
817 user = mommy .make (django_user_model )
918 client .force_login (user )
10- return client .get (reverse ('sections:detail' , kwargs = {'slug' : 'procedural' }))
19+ return client .get (reverse ('sections:detail' , kwargs = {'slug' : section . slug }))
1120
1221
1322def test_status_code (resp ):
1423 assert resp .status_code == 200
24+
25+
26+ @pytest .mark .parametrize ('property_name' , ['title' , 'description' ])
27+ def test_title (resp , section , property_name ):
28+ dj_assert_contains (resp , getattr (section , property_name ))
Original file line number Diff line number Diff line change 1- from django .shortcuts import render
1+ from django .shortcuts import render , get_object_or_404
2+
3+ from pythonpro .sections .models import Section
24
35
46def detail (request , slug ):
5- return render (request , 'sections/section_detail.html' )
7+ ctx = {'section' : get_object_or_404 (Section , slug = slug )}
8+ return render (request , 'sections/section_detail.html' , ctx )
You can’t perform that action at this time.
0 commit comments