Add missing migration file

This commit is contained in:
Oliver Walters 2020-11-12 22:04:50 +11:00
parent ae7fbd6112
commit f239c8f8c8
3 changed files with 51 additions and 14 deletions

View File

@ -39,13 +39,13 @@ script:
- invoke translate - invoke translate
- invoke style - invoke style
# Create an empty database and fill it with test data # Create an empty database and fill it with test data
- rm InvenTree/inventree_default_db.sqlite3 - rm inventree_default_db.sqlite3
- invoke migrate - invoke migrate
- invoke import-fixtures - invoke import-fixtures
# Export database records # Export database records
- invoke export-records -f data.json - invoke export-records -f data.json
# Create a new empty database and import the saved data # Create a new empty database and import the saved data
- rm InvenTree/inventree_default_db.sqlite3 - rm inventree_default_db.sqlite3
- invoke migrate - invoke migrate
- invoke import-records -f data.json - invoke import-records -f data.json

View File

@ -50,17 +50,10 @@ class CompanyViewTestBase(TestCase):
self.client.login(username='username', password='password') self.client.login(username='username', password='password')
def post(self, url, data, valid=None):
class SupplierPartViewTests(CompanyViewTestBase):
"""
Tests for the SupplierPart views.
"""
def post(self, data, valid=None):
""" """
POST against this form and return the response (as a JSON object) 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') response = self.client.post(url, data, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
@ -79,6 +72,14 @@ class SupplierPartViewTests(CompanyViewTestBase):
return json_data, form_errors return json_data, form_errors
class SupplierPartViewTests(CompanyViewTestBase):
"""
Tests for the SupplierPart views.
"""
def test_supplier_part_create(self): def test_supplier_part_create(self):
""" """
Test the SupplierPartCreate view. Test the SupplierPartCreate view.
@ -103,13 +104,13 @@ class SupplierPartViewTests(CompanyViewTestBase):
} }
# SKU is required! (form should fail) # 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)) self.assertIsNotNone(errors.get('SKU', None))
data['SKU'] = 'TEST-ME-123' 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! # Check that the SupplierPart was created!
self.assertEqual(n + 1, SupplierPart.objects.all().count()) self.assertEqual(n + 1, SupplierPart.objects.all().count())
@ -120,7 +121,7 @@ class SupplierPartViewTests(CompanyViewTestBase):
self.assertEqual(supplier_part.price_breaks.count(), 0) self.assertEqual(supplier_part.price_breaks.count(), 0)
# Duplicate SKU is prohibited # 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)) self.assertIsNotNone(errors.get('__all__', None))
@ -129,7 +130,7 @@ class SupplierPartViewTests(CompanyViewTestBase):
data['single_pricing_0'] = '123.4' data['single_pricing_0'] = '123.4'
data['single_pricing_1'] = 'CAD' data['single_pricing_1'] = 'CAD'
(response, errors) = self.post(data, valid=True) (response, errors) = self.post(url, data, valid=True)
pk = response.get('pk') pk = response.get('pk')
@ -186,3 +187,20 @@ class CompanyViewTest(CompanyViewTestBase):
response = self.client.get(reverse('company-index')) response = self.client.get(reverse('company-index'))
self.assertEqual(response.status_code, 200) 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')

View File

@ -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'),
),
]