From b81e7f937c4f92cdd544160e19554bee99b5c0da Mon Sep 17 00:00:00 2001 From: Floris272 Date: Fri, 25 Oct 2024 14:13:55 +0200 Subject: [PATCH] [maykinmedia/open-producten#38] add disable_admin_mfa decorator to action tests --- src/openforms/products/tests/test_admin.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/openforms/products/tests/test_admin.py b/src/openforms/products/tests/test_admin.py index 154d6bcef2..75e269bf08 100644 --- a/src/openforms/products/tests/test_admin.py +++ b/src/openforms/products/tests/test_admin.py @@ -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): @@ -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 @@ -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") @@ -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") @@ -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")