-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ [#4908] Add tests for JSON registration config checks
- Loading branch information
1 parent
c4a5834
commit 1b81a5c
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/openforms/registrations/contrib/json/tests/test_config_checks.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |