Skip to content

Commit

Permalink
✅ [#4908] Add tests for JSON registration config checks
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorvanwijk committed Dec 30, 2024
1 parent c4a5834 commit 1b81a5c
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from unittest.mock import patch

from django.test import TestCase

from zgw_consumers.test.factories import ServiceFactory

from openforms.plugins.exceptions import InvalidPluginConfiguration

from ..models import JSONConfig
from ..plugin import JSONRegistration


class ConfigCheckTests(TestCase):

@patch("zgw_consumers.nlx.NLXClient.get")
def test_config_check(self, mock_post):
json_plugin = JSONRegistration("json_registration_plugin")

config = JSONConfig(
service=ServiceFactory(api_root="https://example.com/", api_connection_check_path="test")
)

with patch(
"openforms.registrations.contrib.json.plugin.JSONConfig.get_solo",
return_value=config
):
json_plugin.check_config()
mock_post.assert_called_once_with("test")

def test_no_service_configured(self):
config = JSONConfig(service=None)
json_plugin = JSONRegistration("json_registration_plugin")

with patch(
"openforms.registrations.contrib.json.plugin.JSONConfig.get_solo",
return_value=config
):
self.assertRaises(InvalidPluginConfiguration, json_plugin.check_config)

0 comments on commit 1b81a5c

Please sign in to comment.