2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-30 04:26:44 +00:00
InvenTree/InvenTree/label/test_api.py
Matthias Mair f38386b13c
Add more checks to pre-commit (#3132)
* Add bandit to pre-commit checks

* fix catchall exceptions

* remove unused definitons

* remove unuseed ariables

* Add docstring

* fix B006, B008 errors

* fix B007 error

* ignore B009

* Add checks for formatting and naming
2022-06-06 08:56:52 +10:00

64 lines
1.4 KiB
Python

"""Unit tests for label API"""
from django.urls import reverse
from InvenTree.api_tester import InvenTreeAPITestCase
class TestReportTests(InvenTreeAPITestCase):
"""Tests for the StockItem TestReport templates."""
fixtures = [
'category',
'part',
'location',
'stock',
]
roles = [
'stock.view',
'stock_location.view',
]
list_url = reverse('api-stockitem-testreport-list')
def do_list(self, filters=None):
"""Helper function to request list of labels with provided filters"""
# Set default - see B006
if filters is None:
filters = {}
response = self.client.get(self.list_url, filters, format='json')
self.assertEqual(response.status_code, 200)
return response.data
def test_list(self):
"""Test the API list endpoint"""
response = self.do_list()
# TODO - Add some report templates to the fixtures
self.assertEqual(len(response), 0)
# TODO - Add some tests to this response
response = self.do_list(
{
'item': 10,
}
)
# TODO - Add some tests to this response
response = self.do_list(
{
'item': 100000,
}
)
# TODO - Add some tests to this response
response = self.do_list(
{
'items': [10, 11, 12],
}
)