Minor proposition tests cleanups
This commit is contained in:
parent
5d6e2c8b4f
commit
9ddba47e83
1 changed files with 8 additions and 10 deletions
|
@ -17,11 +17,11 @@ def new_user(username):
|
|||
class PropositionCreateTest(TestCase):
|
||||
url = reverse_lazy("propositions:create")
|
||||
|
||||
def test_anonymous_get(self):
|
||||
def test_anonymous_cannot_get(self):
|
||||
response = Client().get(self.url)
|
||||
self.assertRedirects(response, "/login?next={}".format(self.url))
|
||||
|
||||
def test_get(self):
|
||||
def test_ernesto_user_can_get(self):
|
||||
user = new_user("toto")
|
||||
client = Client()
|
||||
client.force_login(user)
|
||||
|
@ -29,7 +29,7 @@ class PropositionCreateTest(TestCase):
|
|||
response = client.get(self.url)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_post(self):
|
||||
def test_ernesto_user_can_post(self):
|
||||
user = new_user("toto")
|
||||
client = Client()
|
||||
client.force_login(user)
|
||||
|
@ -116,11 +116,11 @@ class PropositionListTest(TestCase):
|
|||
p = Proposition.objects.create(name=name, user=self.user.profile)
|
||||
Answer.objects.create(proposition=p, user=self.user, answer=Answer.NO)
|
||||
|
||||
def test_anonymous_get(self):
|
||||
def test_anonymous_cannot_get(self):
|
||||
response = Client().get(self.url)
|
||||
self.assertRedirects(response, "/login?next={}".format(self.url))
|
||||
|
||||
def test_get(self):
|
||||
def test_ernesto_user_can_get(self):
|
||||
client = Client()
|
||||
client.force_login(self.user)
|
||||
|
||||
|
@ -134,10 +134,10 @@ class ReponseTest(TestCase):
|
|||
self.prop = Proposition.objects.create(name="foo", user=self.user.profile)
|
||||
|
||||
def _url(self, rep):
|
||||
assert rep in ["oui", "non"]
|
||||
assert rep in Answer.REP_CHOICES
|
||||
return reverse("propositions:{}".format(rep), args=(self.prop.id,))
|
||||
|
||||
def test_anonymous_get(self):
|
||||
def test_anonymous_cannot_get(self):
|
||||
client = Client()
|
||||
|
||||
url = reverse("propositions:oui", args=(self.prop.id,))
|
||||
|
@ -148,18 +148,16 @@ class ReponseTest(TestCase):
|
|||
response = client.get(url)
|
||||
self.assertRedirects(response, "/login?next={}".format(url))
|
||||
|
||||
def test_get(self):
|
||||
def test_ernesto_user_can_get(self):
|
||||
client = Client()
|
||||
client.force_login(self.user)
|
||||
|
||||
# Oui
|
||||
client.get(reverse("propositions:oui", args=(self.prop.id,)))
|
||||
self.prop.refresh_from_db()
|
||||
self.assertEqual(
|
||||
list(self.prop.answer_set.values_list("answer", flat=True)), [Answer.YES],
|
||||
)
|
||||
|
||||
# Oui
|
||||
client.get(reverse("propositions:non", args=(self.prop.id,)))
|
||||
self.prop.refresh_from_db()
|
||||
self.assertEqual(
|
||||
|
|
Loading…
Reference in a new issue