-
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.
✅ [#1068] -- improving test coverage
- Loading branch information
1 parent
1dc3088
commit 536133b
Showing
9 changed files
with
61 additions
and
58 deletions.
There are no files selected for viewing
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
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
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
41 changes: 41 additions & 0 deletions
41
src/openforms/formio/dynamic_config/tests/test_file_component.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,41 @@ | ||
from unittest.mock import patch | ||
|
||
from django.test import TestCase | ||
|
||
from rest_framework.test import APIRequestFactory | ||
|
||
from openforms.config.models import GlobalConfiguration | ||
|
||
from ...datastructures import FormioConfigurationWrapper | ||
from ...service import rewrite_formio_components_for_request | ||
|
||
request_factory = APIRequestFactory() | ||
|
||
|
||
def _get_dynamic_config(component: dict) -> FormioConfigurationWrapper: | ||
wrapper = FormioConfigurationWrapper({"components": [component]}) | ||
request = request_factory.get("/irrelevant") | ||
return rewrite_formio_components_for_request(wrapper, request) | ||
|
||
|
||
@patch( | ||
"openforms.formio.components.vanilla.GlobalConfiguration.get_solo", | ||
return_value=GlobalConfiguration( | ||
form_upload_default_file_types=["image/png", "application/pdf"] | ||
), | ||
) | ||
class FileComponentTests(TestCase): | ||
def test_use_global_config_filetypes(self, m_get_solo): | ||
component = { | ||
"type": "file", | ||
"key": "fileTest", | ||
"url": "", | ||
"useConfigFiletypes": True, | ||
"filePattern": "*", | ||
} | ||
|
||
wrapper = _get_dynamic_config(component) | ||
|
||
updated_component = wrapper["fileTest"] | ||
self.assertEqual(updated_component["filePattern"], "image/png,application/pdf") | ||
self.assertNotEqual(updated_component["url"], "") |
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
This file was deleted.
Oops, something went wrong.
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
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
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