Skip to content

Commit

Permalink
tests: Small improvements onto #1677. Closes #1617
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed Jun 12, 2020
1 parent 694daa7 commit a19dde3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tcms/testplans/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,18 @@ def test_edit_testplan_text_field(self):
self.test_plan_1.refresh_from_db()
self.assertEqual(new_text, self.test_plan_1.text)

# Issue: When there is an invalid value on notify_formset,
# returned response is always the default (ON).
def test_with_invalid_notify_form_value(self):
# Note: Boolean fields are always valid - either False or True
# https://github.com/kiwitcms/Kiwi/pull/1677#discussion_r438776178
# That's why the only way to make the notify formset invalid is to
# reference a non-existing email_settings ID !!!
edit_data = self.testplan_edit_data.copy()
edit_data['email_settings-0-id'] = -1
del edit_data['email_settings-0-auto_to_plan_author']

response = self.client.post(self.testplan_edit_url, data=edit_data, follow=True)

self.assertContains(response, _('Edit TestPlan'))
self.assertContains(
response,
'<input class="bootstrap-switch" name="email_settings-0-auto_to_plan_author" '
Expand All @@ -131,6 +134,7 @@ def test_with_invalid_product_shows_error(self):

response = self.client.post(self.testplan_edit_url, data=edit_data, follow=True)

self.assertContains(response, _('Edit TestPlan'))
self.assertContains(
response,
_('Select a valid choice. That choice is not one of the available choices.'))
Expand All @@ -146,6 +150,7 @@ def test_with_invalid_type_shows_error(self):

response = self.client.post(self.testplan_edit_url, data=edit_data, follow=True)

self.assertContains(response, _('Edit TestPlan'))
self.assertContains(
response,
_('Select a valid choice. That choice is not one of the available choices.'))
Expand All @@ -156,6 +161,8 @@ def test_with_invalid_type_shows_error(self):

def test_with_invalid_version_shows_error(self):
edit_data = self.testplan_edit_data.copy()
# Note: version not assigned to the current Product, that's why
# it is invalid !
version = VersionFactory()
edit_data['product_version'] = version.pk

Expand Down

0 comments on commit a19dde3

Please sign in to comment.