mirror of
https://github.com/inventree/InvenTree.git
synced 2025-10-25 02:17:37 +00:00
extend tests
This commit is contained in:
@@ -1195,6 +1195,7 @@ class BuildListTest(BuildAPITest):
|
|||||||
('user_detail', 'issued_by_detail'),
|
('user_detail', 'issued_by_detail'),
|
||||||
('user_detail', 'responsible_detail'),
|
('user_detail', 'responsible_detail'),
|
||||||
('project_code_detail', 'project_code_detail'),
|
('project_code_detail', 'project_code_detail'),
|
||||||
|
('project_code_detail', 'project_code'),
|
||||||
]
|
]
|
||||||
|
|
||||||
for param, field in test_cases:
|
for param, field in test_cases:
|
||||||
|
|||||||
@@ -1395,6 +1395,34 @@ class PartAPITest(PartAPITestBase):
|
|||||||
|
|
||||||
self.assertIn('notes', response.data)
|
self.assertIn('notes', response.data)
|
||||||
|
|
||||||
|
def test_output_options(self):
|
||||||
|
"""Test the output options for PartList list."""
|
||||||
|
url = reverse('api-part-list')
|
||||||
|
test_cases = [
|
||||||
|
('location_detail', 'default_location_detail'),
|
||||||
|
('parameters', 'parameters'),
|
||||||
|
('path_detail', 'category_path'),
|
||||||
|
('pricing', 'pricing_min'),
|
||||||
|
('pricing', 'pricing_updated'),
|
||||||
|
]
|
||||||
|
|
||||||
|
for param, field in test_cases:
|
||||||
|
# Test with parameter set to 'true'
|
||||||
|
response = self.get(url, {param: 'true', 'limit': 1}, expected_code=200)
|
||||||
|
self.assertIn(
|
||||||
|
field,
|
||||||
|
response.data['results'][0],
|
||||||
|
f"Field '{field}' should be present when {param}='true'",
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test with parameter set to 'false'
|
||||||
|
response = self.get(url, {param: 'false', 'limit': 1}, expected_code=200)
|
||||||
|
self.assertNotIn(
|
||||||
|
field,
|
||||||
|
response.data['results'][0],
|
||||||
|
f"Field '{field}' should not be present when {param}='false'",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class PartCreationTests(PartAPITestBase):
|
class PartCreationTests(PartAPITestBase):
|
||||||
"""Tests for creating new Part instances via the API."""
|
"""Tests for creating new Part instances via the API."""
|
||||||
@@ -2664,10 +2692,11 @@ class BomItemTest(InvenTreeAPITestCase):
|
|||||||
self.assertEqual(int(float(response.data['quantity'])), 57)
|
self.assertEqual(int(float(response.data['quantity'])), 57)
|
||||||
self.assertEqual(response.data['note'], 'Added a note')
|
self.assertEqual(response.data['note'], 'Added a note')
|
||||||
|
|
||||||
|
# TODO add test for (pricing, pricing_min)
|
||||||
def test_output_options(self):
|
def test_output_options(self):
|
||||||
"""Test that various output options work as expected."""
|
"""Test that various output options work as expected."""
|
||||||
url = reverse('api-bom-item-detail', kwargs={'pk': 3})
|
url = reverse('api-bom-item-detail', kwargs={'pk': 3})
|
||||||
options = ['can_build', 'part_detail', 'sub_part_detail']
|
options = ['can_build', 'part_detail', 'sub_part_detail', 'substitutes']
|
||||||
for option in options:
|
for option in options:
|
||||||
response = self.get(url, {f'{option}': True}, expected_code=200)
|
response = self.get(url, {f'{option}': True}, expected_code=200)
|
||||||
self.assertIn(option, response.data)
|
self.assertIn(option, response.data)
|
||||||
|
|||||||
Reference in New Issue
Block a user