code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def test_category(self):
"""Test the PartCategory API OPTIONS endpoint."""
actions = self.getActions(reverse('api-part-category-list'))
# actions should *not* contain 'POST' as we do not have the correct role
self.assertNotIn('POST', actions)
self.assignRole('part_category.add'... | Test the PartCategory API OPTIONS endpoint. | test_category | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_get_categories(self):
"""Test that we can retrieve list of part categories, with various filtering options."""
url = reverse('api-part-category-list')
# Request *all* part categories
response = self.get(url)
self.assertEqual(len(response.data), 8)
# Request to... | Test that we can retrieve list of part categories, with various filtering options. | test_get_categories | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_add_categories(self):
"""Check that we can add categories."""
data = {'name': 'Animals', 'description': 'All animals go here'}
url = reverse('api-part-category-list')
response = self.post(url, data)
parent = response.data['pk']
# Add some sub-categories to the... | Check that we can add categories. | test_add_categories | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_filter_parts(self):
"""Test part filtering using the API."""
url = reverse('api-part-list')
data = {'cascade': True}
response = self.get(url, data)
self.assertEqual(len(response.data), Part.objects.count())
# Test filtering parts by category
data = {'cat... | Test part filtering using the API. | test_filter_parts | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_filter_by_in_bom(self):
"""Test that we can filter part list by the 'in_bom_for' parameter."""
url = reverse('api-part-list')
response = self.get(url, {'in_bom_for': 100}, expected_code=200)
self.assertEqual(len(response.data), 4) | Test that we can filter part list by the 'in_bom_for' parameter. | test_filter_by_in_bom | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_filter_by_related(self):
"""Test that we can filter by the 'related' status."""
url = reverse('api-part-list')
# Initially there are no relations, so this should return zero results
response = self.get(url, {'related': 1}, expected_code=200)
self.assertEqual(len(respons... | Test that we can filter by the 'related' status. | test_filter_by_related | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_filter_by_convert(self):
"""Test that we can correctly filter the Part list by conversion options."""
category = PartCategory.objects.get(pk=3)
# First, construct a set of template / variant parts
master_part = Part.objects.create(
name='Master',
descrip... | Test that we can correctly filter the Part list by conversion options. | test_filter_by_convert | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_include_children(self):
"""Test the special 'include_child_categories' flag.
If provided, parts are provided for ANY child category (recursive)
"""
url = reverse('api-part-list')
data = {'category': 1, 'cascade': True}
# Now request to include child categories
... | Test the special 'include_child_categories' flag.
If provided, parts are provided for ANY child category (recursive)
| test_include_children | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_paginate(self):
"""Test pagination of the Part list API."""
for n in [1, 5, 10]:
response = self.get(reverse('api-part-list'), {'limit': n})
data = response.data
self.assertIn('count', data)
self.assertIn('results', data)
self.asser... | Test pagination of the Part list API. | test_paginate | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_template_filters(self):
"""Unit tests for API filters related to template parts.
Test:
- variant_of : Return children of specified part
- ancestor : Return descendants of specified part
Uses the 'chair template' part (pk=10000)
"""
# Rebuild the MPTT st... | Unit tests for API filters related to template parts.
Test:
- variant_of : Return children of specified part
- ancestor : Return descendants of specified part
Uses the 'chair template' part (pk=10000)
| test_template_filters | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_variant_stock(self):
"""Unit tests for the 'variant_stock' annotation, which provides a stock count for *variant* parts."""
# Ensure the MPTT structure is in a known state before running tests
Part.objects.rebuild()
# Initially, there are no "chairs" in stock,
# so each... | Unit tests for the 'variant_stock' annotation, which provides a stock count for *variant* parts. | test_variant_stock | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_part_download(self):
"""Test download of part data via the API."""
url = reverse('api-part-list')
required_cols = [
'ID',
'Name',
'Description',
'Total Stock',
'Category Name',
'Keywords',
'Is Template'... | Test download of part data via the API. | test_part_download | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_date_filters(self):
"""Test that the creation date filters work correctly."""
url = reverse('api-part-list')
response = self.get(url)
n = len(response.data)
date_compare = datetime.fromisoformat('2019-01-01')
# Filter by creation date
response = self.... | Test that the creation date filters work correctly. | test_date_filters | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_default_values(self):
"""Tests for 'default' values.
Ensure that unspecified fields revert to "default" values
(as specified in the model field definition)
"""
url = reverse('api-part-list')
response = self.post(
url,
{'name': 'all defau... | Tests for 'default' values.
Ensure that unspecified fields revert to "default" values
(as specified in the model field definition)
| test_default_values | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_initial_stock(self):
"""Tests for initial stock quantity creation."""
def submit(stock_data, expected_code=None):
"""Helper function for submitting with initial stock data."""
data = {
'category': 1,
'name': "My lil' test part",
... | Tests for initial stock quantity creation. | test_initial_stock | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_initial_supplier_data(self):
"""Tests for initial creation of supplier / manufacturer data."""
def submit(supplier_data, expected_code=400):
"""Helper function for submitting with supplier data."""
data = {
'name': 'My test part',
'descri... | Tests for initial creation of supplier / manufacturer data. | test_initial_supplier_data | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_category_parameters(self):
"""Test that category parameters are correctly applied."""
cat = PartCategory.objects.get(pk=1)
# Add some parameter template to the parent category
for pk in [1, 2, 3]:
PartCategoryParameterTemplate.objects.create(
paramet... | Test that category parameters are correctly applied. | test_category_parameters | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_part_operations(self):
"""Test that Part instances can be adjusted via the API."""
n = Part.objects.count()
# Create a part
response = self.post(
reverse('api-part-list'),
{
'name': 'my test api part',
'description': 'a pa... | Test that Part instances can be adjusted via the API. | test_part_operations | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_duplicates(self):
"""Check that trying to create 'duplicate' parts results in errors."""
# Create a part
response = self.post(
reverse('api-part-list'),
{
'name': 'part',
'description': 'description',
'IPN': 'IPN-12... | Check that trying to create 'duplicate' parts results in errors. | test_duplicates | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_image_upload(self):
"""Test that we can upload an image to the part API."""
self.assignRole('part.add')
# Create a new part
response = self.post(
reverse('api-part-list'),
{'name': 'imagine', 'description': 'All the people', 'category': 1},
e... | Test that we can upload an image to the part API. | test_image_upload | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_existing_image(self):
"""Test that we can allocate an existing uploaded image to a new Part."""
# First, upload an image for an existing part
image_name = self.create_test_image()
# Attempt to create, but with an invalid image name
response = self.post(
reve... | Test that we can allocate an existing uploaded image to a new Part. | test_existing_image | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_update_existing_image(self):
"""Test that we can update the image of an existing part with an already existing image."""
# First, upload an image for an existing part
p = Part.objects.first()
fn = BASE_DIR / '_testfolder' / 'part_image_123abc.png'
img = PIL.Image.new('... | Test that we can update the image of an existing part with an already existing image. | test_update_existing_image | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_details(self):
"""Test that the required details are available."""
p = Part.objects.get(pk=1)
url = reverse('api-part-detail', kwargs={'pk': 1})
data = self.get(url, expected_code=200).data
# How many parts are 'on order' for this part?
lines = order.models.Pu... | Test that the required details are available. | test_details | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_path_detail(self):
"""Check that path_detail can be requested against the serializer."""
response = self.get(
reverse('api-part-detail', kwargs={'pk': 1}),
{'path_detail': True},
expected_code=200,
)
self.assertIn('category_path', response.da... | Check that path_detail can be requested against the serializer. | test_path_detail | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_query_count(self):
"""Test that the query count is unchanged, independent of query results."""
queries = [{'limit': 1}, {'limit': 10}, {'limit': 50}, {'category': 1}, {}]
url = reverse('api-part-list')
# Create a bunch of extra parts (efficiently)
parts = []
f... | Test that the query count is unchanged, independent of query results. | test_query_count | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_long_notes(self):
"""Test that very long notes field is rejected."""
# Ensure that we cannot upload a very long piece of text
url = reverse('api-part-detail', kwargs={'pk': 1})
response = self.patch(url, {'notes': 'abcde' * 10001}, expected_code=400)
self.assertIn(
... | Test that very long notes field is rejected. | test_long_notes | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_multiline_formatting(self):
"""Ensure that markdown formatting is retained."""
url = reverse('api-part-detail', kwargs={'pk': 1})
notes = """
### Title
1. Numbered list
2. Another item
3. Another item again
[A link](http://link.com.go)
... | Ensure that markdown formatting is retained. | test_multiline_formatting | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def setUpTestData(cls):
"""Create test data as part of setup routine."""
super().setUpTestData()
# Ensure the part "variant" tree is correctly structured
Part.objects.rebuild()
# Add a new part
cls.part = Part.objects.create(
name='Banana',
descr... | Create test data as part of setup routine. | setUpTestData | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def get_part_data(self):
"""Helper function for retrieving part data."""
url = reverse('api-part-list')
response = self.get(url)
for part in response.data:
if part['pk'] == self.part.pk:
return part
# We should never get here!
self.assertTru... | Helper function for retrieving part data. | get_part_data | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_stock_quantity(self):
"""Simple test for the stock quantity."""
data = self.get_part_data()
self.assertEqual(data['in_stock'], 600)
self.assertEqual(data['stock_item_count'], 4)
# Add some more stock items!!
for _ in range(100):
StockItem.objects.cr... | Simple test for the stock quantity. | test_stock_quantity | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_allocation_annotations(self):
"""Tests for query annotations which add allocation information.
Ref: https://github.com/inventree/InvenTree/pull/2797
"""
# We are looking at Part ID 100 ("Bob")
url = reverse('api-part-detail', kwargs={'pk': 100})
part = Part.obj... | Tests for query annotations which add allocation information.
Ref: https://github.com/inventree/InvenTree/pull/2797
| test_allocation_annotations | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_on_order(self):
"""Test that the 'on_order' queryset annotation works as expected.
This queryset annotation takes into account any outstanding line items for active orders,
and should also use the 'pack_size' of the supplier part objects.
"""
supplier = Company.objects.... | Test that the 'on_order' queryset annotation works as expected.
This queryset annotation takes into account any outstanding line items for active orders,
and should also use the 'pack_size' of the supplier part objects.
| test_on_order | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_bom_list_search(self):
"""Test that we can search the BOM list API endpoint."""
url = reverse('api-bom-list')
response = self.get(url, expected_code=200)
self.assertEqual(len(response.data), 6)
# Limit the results with a search term
response = self.get(url, {'... | Test that we can search the BOM list API endpoint. | test_bom_list_search | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_bom_list_ordering(self):
"""Test that the BOM list results can be ordered."""
url = reverse('api-bom-list')
# Order by increasing quantity
response = self.get(f'{url}?ordering=+quantity', expected_code=200)
self.assertEqual(len(response.data), 6)
q1 = response... | Test that the BOM list results can be ordered. | test_bom_list_ordering | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_add_attachment(self):
"""Test that we can create a new PartAttachment via the API."""
url = reverse('api-attachment-list')
# Upload without permission
response = self.post(
url, {'model_id': 1, 'model_type': 'part'}, expected_code=403
)
# Add requir... | Test that we can create a new PartAttachment via the API. | test_add_attachment | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_create_price_breaks(self):
"""Test we can create price breaks at various quantities."""
url = reverse('api-part-internal-price-list')
breaks = [
(1.0, 101),
(1.1, 92.555555555),
(1.5, 90.999999999),
(1.756, 89),
(2, 86),
... | Test we can create price breaks at various quantities. | test_create_price_breaks | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_list_endpoint(self):
"""Test the list endpoint for the stocktake data."""
url = reverse('api-part-stocktake-list')
self.assignRole('part.view')
# Initially, no stocktake entries
response = self.get(url, expected_code=200)
self.assertEqual(len(response.data), 0... | Test the list endpoint for the stocktake data. | test_list_endpoint | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_create_stocktake(self):
"""Test that stocktake entries can be created via the API."""
url = reverse('api-part-stocktake-list')
self.assignRole('stocktake.add')
self.assignRole('stocktake.view')
for p in Part.objects.all():
# Initially no stocktake informati... | Test that stocktake entries can be created via the API. | test_create_stocktake | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_edit_stocktake(self):
"""Test that a Stoctake instance can be edited and deleted via the API.
Note that only 'staff' users can perform these actions.
"""
p = Part.objects.all().first()
st = PartStocktake.objects.create(part=p, quantity=10)
url = reverse('api-p... | Test that a Stoctake instance can be edited and deleted via the API.
Note that only 'staff' users can perform these actions.
| test_edit_stocktake | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_report_generate(self):
"""Test API functionality for generating a new stocktake report."""
url = reverse('api-part-stocktake-report-generate')
# Permission denied, initially
self.assignRole('stocktake.view')
response = self.post(url, data={}, expected_code=403)
... | Test API functionality for generating a new stocktake report. | test_report_generate | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_get_schedule(self):
"""Test that the scheduling endpoint returns OK."""
part_ids = [1, 3, 100, 101]
for pk in part_ids:
url = reverse('api-part-scheduling', kwargs={'pk': pk})
data = self.get(url, expected_code=200).data
for entry in data:
... | Test that the scheduling endpoint returns OK. | test_get_schedule | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_choices(self):
"""Test the 'choices' field for the PartTestTemplate model."""
template = PartTestTemplate.objects.first()
url = reverse('api-part-test-template-detail', kwargs={'pk': template.pk})
# Check OPTIONS response
response = self.options(url)
options = ... | Test the 'choices' field for the PartTestTemplate model. | test_choices | python | inventree/InvenTree | src/backend/InvenTree/part/test_api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_api.py | MIT |
def test_overage(self):
"""Test that BOM line overages are calculated correctly."""
item = BomItem.objects.get(part=100, sub_part=50)
q = 300
item.quantity = q
# Test empty overage
n = item.get_overage_quantity(q)
self.assertEqual(n, 0)
# Test improper... | Test that BOM line overages are calculated correctly. | test_overage | python | inventree/InvenTree | src/backend/InvenTree/part/test_bom_item.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_bom_item.py | MIT |
def test_invalid_bom(self):
"""Test that ValidationError is correctly raised for an invalid BOM item."""
# First test: A BOM item which points to itself
with self.assertRaises(django_exceptions.ValidationError):
BomItem.objects.create(part=self.bob, sub_part=self.bob, quantity=1)
... | Test that ValidationError is correctly raised for an invalid BOM item. | test_invalid_bom | python | inventree/InvenTree | src/backend/InvenTree/part/test_bom_item.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_bom_item.py | MIT |
def setUpTestData(cls):
"""Extract some interesting categories for time-saving."""
super().setUpTestData()
cls.electronics = PartCategory.objects.get(name='Electronics')
cls.mechanical = PartCategory.objects.get(name='Mechanical')
cls.resistors = PartCategory.objects.get(name='R... | Extract some interesting categories for time-saving. | setUpTestData | python | inventree/InvenTree | src/backend/InvenTree/part/test_category.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_category.py | MIT |
def test_parents(self):
"""Test that the parent fields are properly set, based on the test fixtures."""
self.assertEqual(self.resistors.parent, self.electronics)
self.assertEqual(self.capacitors.parent, self.electronics)
self.assertEqual(self.electronics.parent, None)
self.asser... | Test that the parent fields are properly set, based on the test fixtures. | test_parents | python | inventree/InvenTree | src/backend/InvenTree/part/test_category.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_category.py | MIT |
def test_children_count(self):
"""Test that categories have the correct number of children."""
self.assertTrue(self.electronics.has_children)
self.assertTrue(self.mechanical.has_children)
self.assertEqual(len(self.electronics.children.all()), 3)
self.assertEqual(len(self.mechani... | Test that categories have the correct number of children. | test_children_count | python | inventree/InvenTree | src/backend/InvenTree/part/test_category.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_category.py | MIT |
def test_path_string(self):
"""Test that the category path string works correctly."""
# Note that due to data migrations, these fields need to be saved first
self.resistors.save()
self.transceivers.save()
self.assertEqual(str(self.resistors), 'Electronics/Resistors - Resistors')... | Test that the category path string works correctly. | test_path_string | python | inventree/InvenTree | src/backend/InvenTree/part/test_category.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_category.py | MIT |
def test_part_count(self):
"""Test that the Category part count works."""
self.assertEqual(self.fasteners.partcount(), 2)
self.assertEqual(self.capacitors.partcount(), 1)
self.assertEqual(self.electronics.partcount(), 3)
self.assertEqual(self.mechanical.partcount(), 9)
... | Test that the Category part count works. | test_part_count | python | inventree/InvenTree | src/backend/InvenTree/part/test_category.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_category.py | MIT |
def test_parameters(self):
"""Test that the Category parameters are correctly fetched."""
# Check number of SQL queries to iterate other parameters
with self.assertNumQueries(9):
# Prefetch: 3 queries (parts, parameters and parameters_template)
fasteners = self.fasteners.... | Test that the Category parameters are correctly fetched. | test_parameters | python | inventree/InvenTree | src/backend/InvenTree/part/test_category.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_category.py | MIT |
def test_delete(self):
"""Test that category deletion moves the children properly."""
# Delete the 'IC' category and 'Transceiver' should move to be under 'Electronics'
self.assertEqual(self.transceivers.parent, self.ic)
self.assertEqual(self.ic.parent, self.electronics)
self.ic... | Test that category deletion moves the children properly. | test_delete | python | inventree/InvenTree | src/backend/InvenTree/part/test_category.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_category.py | MIT |
def test_category_tree(self):
"""Unit tests for the part category tree structure (MPTT).
Ensure that the MPTT structure is rebuilt correctly,
and the correct ancestor tree is observed.
"""
# Clear out any existing parts
Part.objects.all().delete()
PartCategory.o... | Unit tests for the part category tree structure (MPTT).
Ensure that the MPTT structure is rebuilt correctly,
and the correct ancestor tree is observed.
| test_category_tree | python | inventree/InvenTree | src/backend/InvenTree/part/test_category.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_category.py | MIT |
def test_models_exist(self):
"""Test that the Part model can still be accessed at the end of schema migration."""
Part = self.new_state.apps.get_model('part', 'part')
self.assertEqual(Part.objects.count(), 5)
for part in Part.objects.all():
part.is_template = True
... | Test that the Part model can still be accessed at the end of schema migration. | test_models_exist | python | inventree/InvenTree | src/backend/InvenTree/part/test_migrations.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_migrations.py | MIT |
def prepare(self):
"""Create some parts, and templates with parameters."""
Part = self.old_state.apps.get_model('part', 'part')
PartParameter = self.old_state.apps.get_model('part', 'partparameter')
PartParameterTemlate = self.old_state.apps.get_model(
'part', 'partparametert... | Create some parts, and templates with parameters. | prepare | python | inventree/InvenTree | src/backend/InvenTree/part/test_migrations.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_migrations.py | MIT |
def test_data_migration(self):
"""Test that the template units and values have been updated correctly."""
Part = self.new_state.apps.get_model('part', 'part')
PartParameter = self.new_state.apps.get_model('part', 'partparameter')
PartParameterTemlate = self.new_state.apps.get_model(
... | Test that the template units and values have been updated correctly. | test_data_migration | python | inventree/InvenTree | src/backend/InvenTree/part/test_migrations.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_migrations.py | MIT |
def test_units_migration(self):
"""Test that the units have migrated OK."""
Part = self.new_state.apps.get_model('part', 'part')
part_1 = Part.objects.get(name='Part 1')
part_2 = Part.objects.get(name='Part 2')
part_3 = Part.objects.get(name='Part 3')
part_4 = Part.objec... | Test that the units have migrated OK. | test_units_migration | python | inventree/InvenTree | src/backend/InvenTree/part/test_migrations.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_migrations.py | MIT |
def test_units_migration(self):
"""Test that the new fields have been added correctly."""
PartParameterTemplate = self.new_state.apps.get_model(
'part', 'partparametertemplate'
)
template = PartParameterTemplate.objects.get(name='Template 1')
self.assertEqual(templa... | Test that the new fields have been added correctly. | test_units_migration | python | inventree/InvenTree | src/backend/InvenTree/part/test_migrations.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_migrations.py | MIT |
def test_key_field(self):
"""Self that the key field is created and correctly filled."""
PartTestTemplate = self.new_state.apps.get_model('part', 'parttesttemplate')
for key, value in self.test_keys.items():
template = PartTestTemplate.objects.get(test_name=value)
self.a... | Self that the key field is created and correctly filled. | test_key_field | python | inventree/InvenTree | src/backend/InvenTree/part/test_migrations.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_migrations.py | MIT |
def test_str(self):
"""Test the str representation of the PartParameterTemplate model."""
t1 = PartParameterTemplate.objects.get(pk=1)
self.assertEqual(str(t1), 'Length (mm)')
p1 = PartParameter.objects.get(pk=1)
self.assertEqual(str(p1), 'M2x4 LPHS : Length = 4 (mm)')
... | Test the str representation of the PartParameterTemplate model. | test_str | python | inventree/InvenTree | src/backend/InvenTree/part/test_param.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_param.py | MIT |
def test_invalid_numbers(self):
"""Test that invalid floating point numbers are correctly handled."""
p = Part.objects.first()
t = PartParameterTemplate.objects.create(name='Yaks')
valid_floats = ['-12', '1.234', '17', '3e45', '-12e34']
for value in valid_floats:
pa... | Test that invalid floating point numbers are correctly handled. | test_invalid_numbers | python | inventree/InvenTree | src/backend/InvenTree/part/test_param.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_param.py | MIT |
def test_locked_part(self):
"""Test parameter editing for a locked part."""
part = Part.objects.create(
name='Test Part 3',
description='A part for testing',
category=PartCategory.objects.first(),
IPN='TEST-PART',
)
parameter = PartParamet... | Test parameter editing for a locked part. | test_locked_part | python | inventree/InvenTree | src/backend/InvenTree/part/test_param.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_param.py | MIT |
def test_validate(self):
"""Test that category templates are correctly applied to Part instances."""
# Category templates
n = PartCategoryParameterTemplate.objects.all().count()
self.assertEqual(n, 2)
category = PartCategory.objects.get(pk=8)
t1 = PartParameterTemplate.... | Test that category templates are correctly applied to Part instances. | test_validate | python | inventree/InvenTree | src/backend/InvenTree/part/test_param.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_param.py | MIT |
def test_choice_validation(self):
"""Test that parameter choices are correctly validated."""
template = PartParameterTemplate.objects.create(
name='My Template',
description='A template with choices',
choices='red, blue, green',
)
pass_values = ['red'... | Test that parameter choices are correctly validated. | test_choice_validation | python | inventree/InvenTree | src/backend/InvenTree/part/test_param.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_param.py | MIT |
def test_unit_validation(self):
"""Test validation of 'units' field for PartParameterTemplate."""
# Test that valid units pass
for unit in [
None,
'',
'%',
'mm',
'A',
'm^2',
'Pa',
'V',
'C'... | Test validation of 'units' field for PartParameterTemplate. | test_unit_validation | python | inventree/InvenTree | src/backend/InvenTree/part/test_param.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_param.py | MIT |
def test_param_unit_validation(self):
"""Test that parameters are correctly validated against template units."""
template = PartParameterTemplate.objects.create(name='My Template', units='m')
prt = Part.objects.get(pk=1)
# Test that valid parameters pass
for value in [
... | Test that parameters are correctly validated against template units. | test_param_unit_validation | python | inventree/InvenTree | src/backend/InvenTree/part/test_param.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_param.py | MIT |
def test_param_unit_conversion(self):
"""Test that parameters are correctly converted to template units."""
template = PartParameterTemplate.objects.create(name='My Template', units='m')
tests = {
'1': 1.0,
'-1': -1.0,
'23m': 23.0,
'-89mm': -0.089... | Test that parameters are correctly converted to template units. | test_param_unit_conversion | python | inventree/InvenTree | src/backend/InvenTree/part/test_param.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_param.py | MIT |
def test_param_template_validation(self):
"""Test that part parameter template validation routines work correctly."""
# Checkbox parameter cannot have "units" specified
with self.assertRaises(django_exceptions.ValidationError):
template = PartParameterTemplate(
name='... | Test that part parameter template validation routines work correctly. | test_param_template_validation | python | inventree/InvenTree | src/backend/InvenTree/part/test_param.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_param.py | MIT |
def test_create_param(self):
"""Test that we can create a param via the API."""
url = reverse('api-part-parameter-list')
response = self.post(url, {'part': '2', 'template': '3', 'data': 70})
self.assertEqual(response.status_code, 201)
response = self.get(url)
self.ass... | Test that we can create a param via the API. | test_create_param | python | inventree/InvenTree | src/backend/InvenTree/part/test_param.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_param.py | MIT |
def test_param_detail(self):
"""Tests for the PartParameter detail endpoint."""
url = reverse('api-part-parameter-detail', kwargs={'pk': 5})
response = self.get(url)
self.assertEqual(response.status_code, 200)
data = response.data
self.assertEqual(data['pk'], 5)
... | Tests for the PartParameter detail endpoint. | test_param_detail | python | inventree/InvenTree | src/backend/InvenTree/part/test_param.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_param.py | MIT |
def test_order_parts_by_param(self):
"""Test that we can order parts by a specified parameter."""
def get_param_value(response, template, index):
"""Helper function to extract a parameter value from a response."""
params = response.data[index]['parameters']
for para... | Test that we can order parts by a specified parameter. | test_order_parts_by_param | python | inventree/InvenTree | src/backend/InvenTree/part/test_param.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_param.py | MIT |
def get_param_value(response, template, index):
"""Helper function to extract a parameter value from a response."""
params = response.data[index]['parameters']
for param in params:
if param['template'] == template:
return param['data']
... | Helper function to extract a parameter value from a response. | get_param_value | python | inventree/InvenTree | src/backend/InvenTree/part/test_param.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_param.py | MIT |
def setUpTestData(cls):
"""Setup test data for the filtering tests."""
super().setUpTestData()
cls.url = reverse('api-part-list')
# Create a number of part parameter templates
cls.template_length = PartParameterTemplate.objects.create(
name='Length', description='Le... | Setup test data for the filtering tests. | setUpTestData | python | inventree/InvenTree | src/backend/InvenTree/part/test_param.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_param.py | MIT |
def test_filter_by_length(self):
"""Test basic filtering by length parameter."""
length_filters = [
('_lt', '25', 2),
('_lt', '25 mm', 2),
('_gt', '1 inch', 47),
('', '105', 1),
('_lt', '2 mile', 50),
]
for operator, value, exp... | Test basic filtering by length parameter. | test_filter_by_length | python | inventree/InvenTree | src/backend/InvenTree/part/test_param.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_param.py | MIT |
def test_filter_by_width(self):
"""Test basic filtering by width parameter."""
width_filters = [
('_lt', '102', 19),
('_lte', '102 mm', 20),
('_gte', '0.1 yards', 33),
('', '52mm', 1),
]
for operator, value, expected_count in width_filters... | Test basic filtering by width parameter. | test_filter_by_width | python | inventree/InvenTree | src/backend/InvenTree/part/test_param.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_param.py | MIT |
def test_str2bool(self):
"""Various test for the str2bool template tag."""
self.assertEqual(int(inventree_extras.str2bool('true')), True)
self.assertEqual(int(inventree_extras.str2bool('yes')), True)
self.assertEqual(int(inventree_extras.str2bool('none')), False)
self.assertEqual... | Various test for the str2bool template tag. | test_str2bool | python | inventree/InvenTree | src/backend/InvenTree/part/test_part.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_part.py | MIT |
def setUpTestData(cls):
"""Create some Part instances as part of init routine."""
super().setUpTestData()
cls.r1 = Part.objects.get(name='R_2K2_0805')
cls.r2 = Part.objects.get(name='R_4K7_0603')
cls.c1 = Part.objects.get(name='C_22N_0805')
Part.objects.rebuild() | Create some Part instances as part of init routine. | setUpTestData | python | inventree/InvenTree | src/backend/InvenTree/part/test_part.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_part.py | MIT |
def test_tree(self):
"""Test that the part variant tree is working properly."""
chair = Part.objects.get(pk=10000)
self.assertEqual(chair.get_children().count(), 3)
self.assertEqual(chair.get_descendant_count(), 4)
green = Part.objects.get(pk=10004)
self.assertEqual(gree... | Test that the part variant tree is working properly. | test_tree | python | inventree/InvenTree | src/backend/InvenTree/part/test_part.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_part.py | MIT |
def test_duplicate(self):
"""Test that we cannot create a "duplicate" Part."""
n = Part.objects.count()
cat = PartCategory.objects.get(pk=1)
Part.objects.create(
category=cat,
name='part',
description='description',
IPN='IPN',
... | Test that we cannot create a "duplicate" Part. | test_duplicate | python | inventree/InvenTree | src/backend/InvenTree/part/test_part.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_part.py | MIT |
def test_rename_img(self):
"""Test that an image can be renamed."""
img = rename_part_image(self.r1, 'hello.png')
self.assertEqual(img, os.path.join('part_images', 'hello.png')) | Test that an image can be renamed. | test_rename_img | python | inventree/InvenTree | src/backend/InvenTree/part/test_part.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_part.py | MIT |
def test_stock(self):
"""Test case where there is zero stock."""
res = Part.objects.filter(description__contains='resistor')
for r in res:
self.assertEqual(r.total_stock, 0)
self.assertEqual(r.available_stock, 0) | Test case where there is zero stock. | test_stock | python | inventree/InvenTree | src/backend/InvenTree/part/test_part.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_part.py | MIT |
def test_sell_pricing(self):
"""Check that the sell pricebreaks were loaded."""
self.assertTrue(self.r1.has_price_breaks)
self.assertEqual(self.r1.price_breaks.count(), 2)
# check that the sell pricebreaks work
self.assertEqual(float(self.r1.get_price(1)), 0.15)
self.asse... | Check that the sell pricebreaks were loaded. | test_sell_pricing | python | inventree/InvenTree | src/backend/InvenTree/part/test_part.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_part.py | MIT |
def test_related(self):
"""Unit tests for the PartRelated model."""
# Create a part relationship
# Count before creation
countbefore = PartRelated.objects.count()
PartRelated.objects.create(part_1=self.r1, part_2=self.r2)
self.assertEqual(PartRelated.objects.count(), coun... | Unit tests for the PartRelated model. | test_related | python | inventree/InvenTree | src/backend/InvenTree/part/test_part.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_part.py | MIT |
def test_delete(self):
"""Test delete operation for a Part instance."""
part = Part.objects.first()
for active, locked in [(True, True), (True, False), (False, True)]:
# Cannot delete part if it is active or locked
part.active = active
part.locked = locked
... | Test delete operation for a Part instance. | test_delete | python | inventree/InvenTree | src/backend/InvenTree/part/test_part.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_part.py | MIT |
def test_template_count(self):
"""Tests for the test template functions."""
chair = Part.objects.get(pk=10000)
# Tests for the top-level chair object (nothing above it!)
self.assertEqual(chair.test_templates.count(), 5)
self.assertEqual(chair.getTestTemplates().count(), 5)
... | Tests for the test template functions. | test_template_count | python | inventree/InvenTree | src/backend/InvenTree/part/test_part.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_part.py | MIT |
def test_uniqueness(self):
"""Test names must be unique for this part and also parts above."""
variant = Part.objects.get(pk=10004)
with self.assertRaises(ValidationError):
PartTestTemplate.objects.create(part=variant, test_name='Record weight')
# Test that error is raised ... | Test names must be unique for this part and also parts above. | test_uniqueness | python | inventree/InvenTree | src/backend/InvenTree/part/test_part.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_part.py | MIT |
def make_part(self):
"""Helper function to create a simple part."""
cache.clear()
part = Part.objects.create(
name='Test Part', description='I am but a humble test part', IPN='IPN-123'
)
return part | Helper function to create a simple part. | make_part | python | inventree/InvenTree | src/backend/InvenTree/part/test_part.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_part.py | MIT |
def test_defaults(self):
"""Test that the default values for the part settings are correct."""
cache.clear()
self.assertTrue(part.settings.part_component_default())
self.assertTrue(part.settings.part_purchaseable_default())
self.assertFalse(part.settings.part_salable_default())
... | Test that the default values for the part settings are correct. | test_defaults | python | inventree/InvenTree | src/backend/InvenTree/part/test_part.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_part.py | MIT |
def test_initial(self):
"""Test the 'initial' default values (no default values have been set)."""
cache.clear()
part = self.make_part()
self.assertTrue(part.component)
self.assertTrue(part.purchaseable)
self.assertFalse(part.salable)
self.assertFalse(part.track... | Test the 'initial' default values (no default values have been set). | test_initial | python | inventree/InvenTree | src/backend/InvenTree/part/test_part.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_part.py | MIT |
def test_custom(self):
"""Update some of the part values and re-test."""
for val in [True, False]:
set_global_setting('PART_COMPONENT', val, self.user)
set_global_setting('PART_PURCHASEABLE', val, self.user)
set_global_setting('PART_SALABLE', val, self.user)
... | Update some of the part values and re-test. | test_custom | python | inventree/InvenTree | src/backend/InvenTree/part/test_part.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_part.py | MIT |
def test_duplicate_ipn(self):
"""Test the setting which controls duplicate IPN values."""
# Create a part
Part.objects.create(
name='Hello', description='A thing', IPN='IPN123', revision='A'
)
# Attempt to create a duplicate item (should fail)
with self.asser... | Test the setting which controls duplicate IPN values. | test_duplicate_ipn | python | inventree/InvenTree | src/backend/InvenTree/part/test_part.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_part.py | MIT |
def setUpTestData(cls):
"""Create category and part data as part of setup routine."""
super().setUpTestData()
# Electronics / IC / MCU
cls.category = PartCategory.objects.get(pk=4)
cls.part = Part.objects.create(
category=cls.category,
name='STM32F103',
... | Create category and part data as part of setup routine. | setUpTestData | python | inventree/InvenTree | src/backend/InvenTree/part/test_part.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_part.py | MIT |
def test_parent_category_subscription(self):
"""Check that a parent category can be subscribed to."""
# Top-level "electronics" category
cat = PartCategory.objects.get(pk=1)
cat.set_starred(self.user, True)
# Check base category
self.assertTrue(cat.is_starred_by(self.us... | Check that a parent category can be subscribed to. | test_parent_category_subscription | python | inventree/InvenTree | src/backend/InvenTree/part/test_part.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_part.py | MIT |
def setUpTestData(cls):
"""Add an email address as part of initialization."""
super().setUpTestData()
# Add email address
EmailAddress.objects.create(user=cls.user, email='test@testing.com')
# Define part that will be tested
cls.part = Part.objects.get(name='R_2K2_0805'... | Add an email address as part of initialization. | setUpTestData | python | inventree/InvenTree | src/backend/InvenTree/part/test_part.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_part.py | MIT |
def _notification_run(self, run_class=None):
"""Run a notification test suit through.
If you only want to test one class pass it to run_class
"""
# reload notification methods
storage.collect(run_class)
NotificationEntry.objects.all().delete()
# There should be... | Run a notification test suit through.
If you only want to test one class pass it to run_class
| _notification_run | python | inventree/InvenTree | src/backend/InvenTree/part/test_part.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_part.py | MIT |
def create_price_breaks(self):
"""Create some price breaks for the part, in various currencies."""
# First supplier part (CAD)
self.supplier_1 = company.models.Company.objects.create(
name='Supplier 1', is_supplier=True
)
self.sp_1 = company.models.SupplierPart.objec... | Create some price breaks for the part, in various currencies. | create_price_breaks | python | inventree/InvenTree | src/backend/InvenTree/part/test_pricing.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_pricing.py | MIT |
def test_pricing_data(self):
"""Test link between Part and PartPricing model."""
# Initially there is no associated Pricing data
with self.assertRaises(ObjectDoesNotExist):
pricing = self.part.pricing_data
# Accessing in this manner should create the associated PartPricing i... | Test link between Part and PartPricing model. | test_pricing_data | python | inventree/InvenTree | src/backend/InvenTree/part/test_pricing.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_pricing.py | MIT |
def test_stock_item_pricing(self):
"""Test for stock item pricing data."""
# Create a part
p = part.models.Part.objects.create(
name='Test part for pricing',
description='hello world, this is a part description',
)
# Create some stock items
prices... | Test for stock item pricing data. | test_stock_item_pricing | python | inventree/InvenTree | src/backend/InvenTree/part/test_pricing.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_pricing.py | MIT |
def test_bom_pricing(self):
"""Unit test for BOM pricing calculations."""
pricing = self.part.pricing
self.assertIsNone(pricing.bom_cost_min)
self.assertIsNone(pricing.bom_cost_max)
currency = 'AUD'
# Create pricing out of order, to ensure min/max values are calculated... | Unit test for BOM pricing calculations. | test_bom_pricing | python | inventree/InvenTree | src/backend/InvenTree/part/test_pricing.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_pricing.py | MIT |
def test_purchase_pricing(self):
"""Unit tests for historical purchase pricing."""
self.create_price_breaks()
pricing = self.part.pricing
# Pre-calculation, pricing should be null
self.assertIsNone(pricing.purchase_cost_min)
self.assertIsNone(pricing.purchase_cost_max)... | Unit tests for historical purchase pricing. | test_purchase_pricing | python | inventree/InvenTree | src/backend/InvenTree/part/test_pricing.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_pricing.py | MIT |
def test_delete_with_pricing(self):
"""Test for deleting a part which has pricing information."""
# Create some pricing data
self.create_price_breaks()
# Check that pricing does exist
pricing = self.part.pricing
pricing.update_pricing()
pricing.save()
s... | Test for deleting a part which has pricing information. | test_delete_with_pricing | python | inventree/InvenTree | src/backend/InvenTree/part/test_pricing.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/part/test_pricing.py | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.