From 697a3387003e6b4e67e4e689141e51c1f395a6aa Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 18 Jan 2021 22:14:38 +1100 Subject: [PATCH] Add a smattering of unit tests --- InvenTree/label/test_api.py | 70 ++++++++++++++++++++++++++++ InvenTree/label/tests.py | 2 +- InvenTree/templates/stock_table.html | 6 +-- 3 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 InvenTree/label/test_api.py diff --git a/InvenTree/label/test_api.py b/InvenTree/label/test_api.py new file mode 100644 index 0000000000..1fc0a3e0da --- /dev/null +++ b/InvenTree/label/test_api.py @@ -0,0 +1,70 @@ +# Tests for labels + +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from rest_framework.test import APITestCase + +from django.urls import reverse +from django.contrib.auth import get_user_model + + +class TestReportTests(APITestCase): + """ + Tests for the StockItem TestReport templates + """ + + fixtures = [ + 'category', + 'part', + 'location', + 'stock', + ] + + list_url = reverse('api-stockitem-testreport-list') + + def setUp(self): + user = get_user_model() + + self.user = user.objects.create_user('testuser', 'test@testing.com', 'password') + + self.user.is_staff = True + self.user.save() + + self.client.login(username='testuser', password='password') + + def do_list(self, filters={}): + + response = self.client.get(self.list_url, filters, format='json') + + self.assertEqual(response.status_code, 200) + + return response.data + + def test_list(self): + + 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], + } + ) diff --git a/InvenTree/label/tests.py b/InvenTree/label/tests.py index dcb051c929..aaf93fd0a0 100644 --- a/InvenTree/label/tests.py +++ b/InvenTree/label/tests.py @@ -1,4 +1,4 @@ -# Tests for Part Parameters +# Tests for labels # -*- coding: utf-8 -*- from __future__ import unicode_literals diff --git a/InvenTree/templates/stock_table.html b/InvenTree/templates/stock_table.html index 131856e016..130a67c6e6 100644 --- a/InvenTree/templates/stock_table.html +++ b/InvenTree/templates/stock_table.html @@ -43,9 +43,9 @@ {% endif %} {% endif %} - -
- +
+ +