diff --git a/.travis.yml b/.travis.yml index a65f16b593..52d0ef1c5c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,13 +39,13 @@ script: - invoke translate - invoke style # Create an empty database and fill it with test data - - rm InvenTree/inventree_default_db.sqlite3 + - rm inventree_default_db.sqlite3 - invoke migrate - invoke import-fixtures # Export database records - invoke export-records -f data.json # Create a new empty database and import the saved data - - rm InvenTree/inventree_default_db.sqlite3 + - rm inventree_default_db.sqlite3 - invoke migrate - invoke import-records -f data.json diff --git a/InvenTree/company/test_views.py b/InvenTree/company/test_views.py index 951d9d759b..9fbe0e01f5 100644 --- a/InvenTree/company/test_views.py +++ b/InvenTree/company/test_views.py @@ -50,17 +50,10 @@ class CompanyViewTestBase(TestCase): self.client.login(username='username', password='password') - -class SupplierPartViewTests(CompanyViewTestBase): - """ - Tests for the SupplierPart views. - """ - - def post(self, data, valid=None): + def post(self, url, data, valid=None): """ POST against this form and return the response (as a JSON object) """ - url = reverse('supplier-part-create') response = self.client.post(url, data, HTTP_X_REQUESTED_WITH='XMLHttpRequest') @@ -79,6 +72,14 @@ class SupplierPartViewTests(CompanyViewTestBase): return json_data, form_errors + + +class SupplierPartViewTests(CompanyViewTestBase): + """ + Tests for the SupplierPart views. + """ + + def test_supplier_part_create(self): """ Test the SupplierPartCreate view. @@ -103,13 +104,13 @@ class SupplierPartViewTests(CompanyViewTestBase): } # SKU is required! (form should fail) - (response, errors) = self.post(data, valid=False) + (response, errors) = self.post(url, data, valid=False) self.assertIsNotNone(errors.get('SKU', None)) data['SKU'] = 'TEST-ME-123' - (response, errors) = self.post(data, valid=True) + (response, errors) = self.post(url, data, valid=True) # Check that the SupplierPart was created! self.assertEqual(n + 1, SupplierPart.objects.all().count()) @@ -120,7 +121,7 @@ class SupplierPartViewTests(CompanyViewTestBase): self.assertEqual(supplier_part.price_breaks.count(), 0) # Duplicate SKU is prohibited - (response, errors) = self.post(data, valid=False) + (response, errors) = self.post(url, data, valid=False) self.assertIsNotNone(errors.get('__all__', None)) @@ -129,7 +130,7 @@ class SupplierPartViewTests(CompanyViewTestBase): data['single_pricing_0'] = '123.4' data['single_pricing_1'] = 'CAD' - (response, errors) = self.post(data, valid=True) + (response, errors) = self.post(url, data, valid=True) pk = response.get('pk') @@ -186,3 +187,20 @@ class CompanyViewTest(CompanyViewTestBase): response = self.client.get(reverse('company-index')) self.assertEqual(response.status_code, 200) + + def test_company_create(self): + """ + Test the view for creating a company + """ + + url = reverse('company-create') + + # Check that different company types return different form titles + response = self.client.get(reverse('supplier-create'), HTTP_X_REQUESTED_WITH='XMLHttpRequest') + self.assertContains(response, 'Create new Supplier') + + response = self.client.get(reverse('manufacturer-create'), HTTP_X_REQUESTED_WITH='XMLHttpRequest') + self.assertContains(response, 'Create new Manufacturer') + + response = self.client.get(reverse('customer-create'), HTTP_X_REQUESTED_WITH='XMLHttpRequest') + self.assertContains(response, 'Create new Customer') diff --git a/InvenTree/order/migrations/0039_auto_20201112_2203.py b/InvenTree/order/migrations/0039_auto_20201112_2203.py new file mode 100644 index 0000000000..bff585688d --- /dev/null +++ b/InvenTree/order/migrations/0039_auto_20201112_2203.py @@ -0,0 +1,19 @@ +# Generated by Django 3.0.7 on 2020-11-12 11:03 + +from django.db import migrations +import djmoney.models.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('order', '0038_auto_20201112_1737'), + ] + + operations = [ + migrations.AlterField( + model_name='purchaseorderlineitem', + name='purchase_price', + field=djmoney.models.fields.MoneyField(blank=True, decimal_places=4, default_currency='USD', help_text='Unit purchase price', max_digits=19, null=True, verbose_name='Purchase Price'), + ), + ]