Skip to content

Commit

Permalink
#280 Refactroring tests names
Browse files Browse the repository at this point in the history
  • Loading branch information
viliambalaz committed Jan 9, 2022
1 parent 937665e commit c4922ce
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
15 changes: 0 additions & 15 deletions chcemvediet/apps/inforequests/tests/render_query_pattern.py

This file was deleted.

15 changes: 15 additions & 0 deletions chcemvediet/apps/inforequests/tests/render_query_patterns.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from poleno.utils.misc import squeeze


base = [
u'FROM "accounts_profile" WHERE "accounts_profile"."user_id" = %s LIMIT 21',
squeeze(u"""
SELECT COUNT\(\*\) FROM "mail_message"
INNER JOIN "inforequests_inforequestemail" ON \( "mail_message"."id" = "inforequests_inforequestemail"."email_id" \)
INNER JOIN "inforequests_inforequest" ON \( "inforequests_inforequestemail"."inforequest_id" = "inforequests_inforequest"."id" \)
WHERE \("inforequests_inforequestemail"."type" = %s
AND "inforequests_inforequest"."applicant_id" = %s
AND "inforequests_inforequest"."closed" = %s\)
"""),
u'FROM "invitations_invitationsupply" WHERE "invitations_invitationsupply"."user_id" = %s LIMIT 21',
]
24 changes: 12 additions & 12 deletions chcemvediet/apps/inforequests/tests/test_views/test_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from poleno.utils.urls import reverse

from .. import InforequestsTestCaseMixin
from .. import render_query_pattern
from .. import render_query_patterns


class DetailViewTest(InforequestsTestCaseMixin, ViewTestCaseMixin, TestCase):
Expand Down Expand Up @@ -81,7 +81,7 @@ def test_inforequest_with_single_branch(self):
def test_inforequest_with_single_branch_related_models_are_prefetched_before_render(self):
inforequest, _, _ = self._create_inforequest_scenario(u'confirmation', u'reversion')
self._login_user()
with self.assertQueriesDuringRender(render_query_pattern.base):
with self.assertQueriesDuringRender(render_query_patterns.base):
response = self.client.get(reverse(u'inforequests:detail', args=(inforequest.slug, inforequest.pk)))

def test_inforequest_with_multiple_branches(self):
Expand Down Expand Up @@ -126,7 +126,7 @@ def test_inforequest_with_multiple_branches_related_models_are_prefetched_before
[u'confirmation', (u'advancement', [u'refusal'])]),
)
self._login_user()
with self.assertQueriesDuringRender(render_query_pattern.base):
with self.assertQueriesDuringRender(render_query_patterns.base):
response = self.client.get(reverse(u'inforequests:detail', args=(inforequest.slug, inforequest.pk)))

def test_inforequest_with_undecided_email(self):
Expand All @@ -150,7 +150,7 @@ def test_inforequest_with_undecided_email_related_models_are_prefetched_before_r
self._create_inforequest_email(inforequest=inforequest)

self._login_user()
with self.assertQueriesDuringRender(render_query_pattern.base):
with self.assertQueriesDuringRender(render_query_patterns.base):
response = self.client.get(reverse(u'inforequests:detail', args=(inforequest.slug, inforequest.pk)))

def test_inforequest_without_undecided_email(self):
Expand All @@ -166,7 +166,7 @@ def test_inforequest_without_undecided_email(self):
def test_inforequest_without_undecided_email_related_models_are_prefetched_before_render(self):
inforequest, _, _ = self._create_inforequest_scenario()
self._login_user()
with self.assertQueriesDuringRender(render_query_pattern.base):
with self.assertQueriesDuringRender(render_query_patterns.base):
response = self.client.get(reverse(u'inforequests:detail', args=(inforequest.slug, inforequest.pk)))

def test_closed_inforequest_with_undecided_email(self):
Expand Down Expand Up @@ -198,10 +198,10 @@ def test_closed_inforequest_related_models_are_prefetched_before_render(self):
self._create_inforequest_email(inforequest=inforequest)

self._login_user()
with self.assertQueriesDuringRender(render_query_pattern.base):
with self.assertQueriesDuringRender(render_query_patterns.base):
response = self.client.get(reverse(u'inforequests:detail', args=(inforequest.slug, inforequest.pk)))

def test_inforequest_with_undecided_email_can_applicant_snooze(self):
def test_inforequest_with_undecided_email_cannot_applicant_snooze(self):
inforequest, _, _ = self._create_inforequest_scenario(
(u'request', dict(legal_date=naive_date(u'2010-10-05'), delivered_date=naive_date(u'2010-10-05')))
)
Expand All @@ -224,7 +224,7 @@ def test_inforequest_without_undecided_email_can_applicant_snooze(self):
self.assertTrue(inforequest.last_action.can_applicant_snooze)
self.assertContains(response, u'type="button" action="{}"'.format(snooze_url))

def test_closed_inforequest_without_undecided_email_can_applicant_snooze(self):
def test_closed_inforequest_without_undecided_email_cannot_applicant_snooze(self):
inforequest, _, _ = self._create_inforequest_scenario(dict(closed=True),
(u'request', dict(legal_date=naive_date(u'2010-10-05'), delivered_date=naive_date(u'2010-10-05')))
)
Expand All @@ -235,7 +235,7 @@ def test_closed_inforequest_without_undecided_email_can_applicant_snooze(self):
self.assertTrue(inforequest.last_action.can_applicant_snooze)
self.assertNotContains(response, u'type="button" action="{}"'.format(snooze_url))

def test_inforequest_with_undecided_email_applicant_can_add_clarification_response(self):
def test_inforequest_with_undecided_email_applicant_cannot_add_clarification_response(self):
inforequest, _, _ = self._create_inforequest_scenario(u'clarification_request')
self._create_inforequest_email(inforequest=inforequest)
self._login_user()
Expand All @@ -252,15 +252,15 @@ def test_inforequest_without_undecided_email_applicant_can_add_clarification_res
self.assertTrue(inforequest.can_add_clarification_response)
self.assertContains(response, u'href="{}"'.format(clarification_response_url))

def test_closed_inforequest_without_undecided_email_applicant_can_add_clarification_response(self):
def test_closed_inforequest_without_undecided_email_applicant_cannot_add_clarification_response(self):
inforequest, _, _ = self._create_inforequest_scenario(dict(closed=True), u'clarification_request')
self._login_user()
response = self.client.get(reverse(u'inforequests:detail', args=(inforequest.slug, inforequest.pk)))
clarification_response_url = url(u'inforequests:clarification_response', branch=inforequest.main_branch)
self.assertTrue(inforequest.can_add_clarification_response)
self.assertNotContains(response, u'href="{}"'.format(clarification_response_url))

def test_inforequest_with_undecided_email_applicant_can_add_appeal(self):
def test_inforequest_with_undecided_email_applicant_cannot_add_appeal(self):
inforequest, _, _ = self._create_inforequest_scenario(u'advancement')
self._create_inforequest_email(inforequest=inforequest)
self._login_user()
Expand All @@ -277,7 +277,7 @@ def test_inforequest_without_undecided_email_applicant_can_add_appeal(self):
self.assertTrue(inforequest.can_add_appeal)
self.assertContains(response, u'href="{}"'.format(appeal_url))

def test_closed_inforequest_without_undecided_email_applicant_can_add_appeal(self):
def test_closed_inforequest_without_undecided_email_applicant_cannot_add_appeal(self):
inforequest, _, _ = self._create_inforequest_scenario(dict(closed=True), u'advancement')
self._login_user()
response = self.client.get(reverse(u'inforequests:detail', args=(inforequest.slug, inforequest.pk)))
Expand Down
4 changes: 2 additions & 2 deletions chcemvediet/apps/inforequests/tests/test_views/test_mine.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from poleno.utils.test import ViewTestCaseMixin
from poleno.utils.urls import reverse

from .. import render_query_pattern
from .. import render_query_patterns
from .. import InforequestsTestCaseMixin
from ...models import Action

Expand Down Expand Up @@ -134,7 +134,7 @@ def pre_mock_render(request, template, context):
"""),
] * 3
patterns = list(
render_query_pattern.base +
render_query_patterns.base +
patterns_pending_inforequests +
patterns_successful_inforequests +
patterns_unsuccessful_inforequests
Expand Down

0 comments on commit c4922ce

Please sign in to comment.