Skip to content

Commit

Permalink
[maykinmedia/open-producten#38] add disable_admin_mfa decorator to ac…
Browse files Browse the repository at this point in the history
…tion tests
  • Loading branch information
Floris272 committed Oct 25, 2024
1 parent b6da19a commit b81e7f9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/openforms/products/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
from django.test import TestCase, override_settings
from django.urls import reverse

from maykin_2fa.test import disable_admin_mfa

from openforms.accounts.tests.factories import SuperUserFactory
from openforms.contrib.open_producten.generate_form import FormGenerationException
from openforms.contrib.open_producten.tests.factories import PriceFactory
from openforms.products.tests.factories import ProductFactory


@disable_admin_mfa()
@override_settings(LANGUAGE_CODE="en")
class TestProductAdmin(TestCase):

Expand All @@ -32,13 +35,11 @@ def test_generate_form_action_with_product_that_has_price(

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

mock_generate_product_form.assert_called_once()
self.assertEqual(response.status_code, 200)
mock_generate_product_form.assert_called_once()
self.assertContains(response, "1 form(s) generated")
self.assertNotContains(response, "error")

self.client.logout()

@patch("openforms.products.admin.product.generate_product_form")
def test_generate_form_action_with_product_that_has_no_price(
self, mock_generate_product_form
Expand All @@ -48,8 +49,8 @@ def test_generate_form_action_with_product_that_has_no_price(

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

mock_generate_product_form.assert_not_called()
self.assertEqual(response.status_code, 200)
mock_generate_product_form.assert_not_called()
self.assertContains(response, "0 form(s) generated")
self.assertNotContains(response, "error")

Expand All @@ -67,8 +68,8 @@ def test_generate_form_action_with_form_generation_exception(

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

mock_generate_product_form.assert_called_once()
self.assertEqual(response.status_code, 200)
mock_generate_product_form.assert_called_once()
self.assertContains(response, "0 form(s) generated")
self.assertContains(response, "error")
self.assertContains(response, "Test error")
Expand All @@ -91,7 +92,7 @@ def test_generate_form_action_with_multiple_products(

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

mock_generate_product_form.assert_called_once()
self.assertEqual(response.status_code, 200)
mock_generate_product_form.assert_called_once()
self.assertContains(response, "1 form(s) generated")
self.assertNotContains(response, "error")

0 comments on commit b81e7f9

Please sign in to comment.