mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add unit test for multiple-choice setting type
This commit is contained in:
parent
eabe082f0a
commit
f972551246
@ -247,7 +247,43 @@ class SettingsApiTest(InvenTreeAPITestCase):
|
|||||||
...
|
...
|
||||||
|
|
||||||
def test_user_setting_choice(self):
|
def test_user_setting_choice(self):
|
||||||
...
|
|
||||||
|
setting = InvenTreeUserSetting.get_setting_object(
|
||||||
|
'DATE_DISPLAY_FORMAT',
|
||||||
|
user=self.user
|
||||||
|
)
|
||||||
|
|
||||||
|
url = reverse('api-user-setting-detail', kwargs={'pk': setting.pk})
|
||||||
|
|
||||||
|
# Check default value
|
||||||
|
self.assertEqual(setting.value, 'YYYY-MM-DD')
|
||||||
|
|
||||||
|
# Check that a valid option can be assigned via the API
|
||||||
|
for opt in ['YYYY-MM-DD', 'DD-MM-YYYY', 'MM/DD/YYYY']:
|
||||||
|
|
||||||
|
self.patch(
|
||||||
|
url,
|
||||||
|
{
|
||||||
|
'value': opt,
|
||||||
|
},
|
||||||
|
expected_code=200,
|
||||||
|
)
|
||||||
|
|
||||||
|
setting.refresh_from_db()
|
||||||
|
self.assertEqual(setting.value, opt)
|
||||||
|
|
||||||
|
# Send an invalid option
|
||||||
|
for opt in ['cat', 'dog', 12345]:
|
||||||
|
|
||||||
|
response = self.patch(
|
||||||
|
url,
|
||||||
|
{
|
||||||
|
'value': opt,
|
||||||
|
},
|
||||||
|
expected_code=400,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertIn('Chosen value is not a valid option', str(response.data))
|
||||||
|
|
||||||
def test_user_setting_integer(self):
|
def test_user_setting_integer(self):
|
||||||
...
|
...
|
||||||
|
Loading…
Reference in New Issue
Block a user