forked from DGNum/gestioCOF
petitcours.tests -- Add tests for demandes list and details views
This commit is contained in:
parent
25dfe2f496
commit
1a5bbf32a4
1 changed files with 56 additions and 1 deletions
|
@ -19,7 +19,7 @@ from gestioncof.autocomplete import Clipper
|
|||
from gestioncof.models import CalendarSubscription, Club, Event, Survey, SurveyAnswer
|
||||
from gestioncof.tests.testcases import ViewTestCaseMixin
|
||||
|
||||
from .utils import create_member, create_root, create_user
|
||||
from .utils import create_member, create_petitcours_demande, create_root, create_user
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
@ -1240,3 +1240,58 @@ class SurveyStatusViewTests(ViewTestCaseMixin, TestCase):
|
|||
|
||||
def test_filter_no(self):
|
||||
self._test_filters([(self.qa1, "no")], [self.a2])
|
||||
|
||||
|
||||
class PetitCoursDemandeListViewTestCase(ViewTestCaseMixin, TestCase):
|
||||
url_name = "petits-cours-demandes-list"
|
||||
url_expected = "/petitcours/demandes"
|
||||
|
||||
auth_user = "staff"
|
||||
auth_forbidden = [None, "user", "member"]
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.demande1 = create_petitcours_demande()
|
||||
self.demande2 = create_petitcours_demande()
|
||||
self.demande3 = create_petitcours_demande()
|
||||
|
||||
def test_get(self):
|
||||
resp = self.client.get(self.url)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
self.assertEqual(len(resp.context["object_list"]), 3)
|
||||
|
||||
def test_pagination(self):
|
||||
for _ in range(21):
|
||||
create_petitcours_demande()
|
||||
|
||||
# Page 1
|
||||
resp = self.client.get(self.url)
|
||||
self.assertEqual(resp.context["page_obj"].paginator.num_pages, 2)
|
||||
self.assertEqual(len(resp.context["object_list"]), 20)
|
||||
|
||||
# Page 2
|
||||
resp = self.client.get(self.url, {"page": 2})
|
||||
self.assertEqual(len(resp.context["object_list"]), 3 + 1)
|
||||
|
||||
|
||||
class PetitCoursDemandeDetailListViewTestCase(ViewTestCaseMixin, TestCase):
|
||||
url_name = "petits-cours-demande-details"
|
||||
|
||||
auth_user = "staff"
|
||||
auth_forbidden = [None, "user", "member"]
|
||||
|
||||
@property
|
||||
def url_kwargs(self):
|
||||
return {"pk": self.demande.pk}
|
||||
|
||||
@property
|
||||
def url_expected(self):
|
||||
return "/petitcours/demandes/{}".format(self.demande.pk)
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.demande = create_petitcours_demande()
|
||||
|
||||
def test_get(self):
|
||||
resp = self.client.get(self.url)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
|
|
Loading…
Reference in a new issue