mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
removed unused import
added unit tests for PART_NAME_FORMAT
This commit is contained in:
parent
2bf51b0ac3
commit
4fddc656c4
@ -136,3 +136,25 @@ class SettingsViewTest(TestCase):
|
||||
for value in [False, 'False']:
|
||||
self.post(url, {'value': value}, valid=True)
|
||||
self.assertFalse(InvenTreeSetting.get_setting('PART_COMPONENT'))
|
||||
|
||||
def test_part_name_format(self):
|
||||
"""
|
||||
Try posting some valid and invalid name formats for PART_NAME_FORMAT
|
||||
"""
|
||||
setting = InvenTreeSetting.get_setting_object('PART_NAME_FORMAT')
|
||||
|
||||
# test default value
|
||||
self.assertEqual(setting.value, "{{ part.IPN if part.IPN }} {{ '|' if part.IPN }} {{ part.name }} "
|
||||
"{{ '|' if part.revision }} {{ part.revision }}")
|
||||
|
||||
url = self.get_url(setting.pk)
|
||||
|
||||
# Try posting an invalid part name format
|
||||
invalid_values = ['{{asset.IPN}}', '{{part}}', '{{"|"}}']
|
||||
for invalid_value in invalid_values:
|
||||
self.post(url, {'value': invalid_value}, valid=False)
|
||||
|
||||
# try posting valid value
|
||||
new_format = "{{ part.name if part.name }} {{ ' with revision ' if part.revision }} {{ part.revision }}"
|
||||
self.post(url, {'value': new_format}, valid=True)
|
||||
|
||||
|
@ -8,7 +8,6 @@ import decimal
|
||||
|
||||
import os
|
||||
import logging
|
||||
import re
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.core.exceptions import ValidationError
|
||||
|
Loading…
Reference in New Issue
Block a user