diff --git a/setup.py b/setup.py index e397d23d..a2ab80c5 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ def read(fname): #Dependencies - python eggs install_requires = [ 'setuptools', - 'Django==1.3.3', + 'Django >= 1.4', #'httplib2', 'south', 'django-rosetta', diff --git a/src/ets/fixtures/compas.json b/src/ets/fixtures/compas.json index c1e43c2c..d624cf80 100644 --- a/src/ets/fixtures/compas.json +++ b/src/ets/fixtures/compas.json @@ -91,6 +91,16 @@ "email": "TEST.FRISCH@WFP.ORG" } }, + { + "pk": "MIX", + "model": "ets.commoditycategory", + "fields": {} + }, + { + "pk": "SED", + "model": "ets.commoditycategory", + "fields": {} + }, { "pk": "LMIX", "model": "ets.lossdamagetype", @@ -422,7 +432,7 @@ } }, { - "pk": "ISBX00312A", + "pk": "ISBX00312AP", "model": "compas.dispatchmaster", "fields": { "document_code": "AB", diff --git a/src/ets/fixtures/development.json b/src/ets/fixtures/development.json index 9337169f..956785d3 100644 --- a/src/ets/fixtures/development.json +++ b/src/ets/fixtures/development.json @@ -235,6 +235,7 @@ "transport_driver_licence": "EG234454", "container_two_number": "", "destination": "ISBX002", + "receipt_warehouse": "ISBX002", "container_two_seal_number": "", "transport_trailer_registration": "", "date_removed": null, diff --git a/src/ets/fixtures/warehouse.json b/src/ets/fixtures/warehouse.json index 2f8e5d31..ed2ad2e2 100644 --- a/src/ets/fixtures/warehouse.json +++ b/src/ets/fixtures/warehouse.json @@ -31,5 +31,35 @@ "organization": "WFP", "start_date": "2011-10-17" } + }, + { + "pk": "ISBX", + "model": "ets.location", + "fields": { + "country": "586", + "name": "ISLAMABAD_CAP" + } + }, + { + "pk": "OE7X", + "model": "ets.location", + "fields": { + "country": "586", + "name": "THARPARKAR" + } + }, + { + "pk": "DOEAF", + "model": "ets.organization", + "fields": { + "name": "First consignee in our system" + } + }, + { + "pk": "WFP", + "model": "ets.organization", + "fields": { + "name": "World Food Program" + } } ] diff --git a/src/ets/tests/test_compas.py b/src/ets/tests/test_compas.py index d623296e..4528edc2 100644 --- a/src/ets/tests/test_compas.py +++ b/src/ets/tests/test_compas.py @@ -27,9 +27,9 @@ def test_sync_compas(self): self.assertEqual(ets.models.Compas.objects.count(), 1) self.assertEqual(compas_models.Place.objects.using(self.compas).count(), 3) - self.assertEqual(ets.models.Location.objects.count(), 0) + self.assertEqual(ets.models.Location.objects.count(), 2) self.assertEqual(ets.models.Warehouse.objects.count(), 3) - self.assertEqual(ets.models.Organization.objects.count(), 0) + self.assertEqual(ets.models.Organization.objects.count(), 2) call_command('import_compas_full') call_command('sync_compas') @@ -113,7 +113,7 @@ def call_db_procedure(name, parameters, using): #Send all validated waybills to compas send_dispatched(waybill, self.compas) - + self.assertTrue(ets.models.Waybill.objects.get(pk="ISBX00211A").sent_compas) #Check compass logger @@ -160,6 +160,14 @@ def call_db_procedure(name, parameters, using): waybill.save() #Send all validated waybills to compas + send_dispatched(ets.models.Waybill.objects.get(pk="ISBX00312A"), self.compas) + ets.models.CompasLogger.objects.filter(waybill__pk='ISBX00312A').delete() + compas_models.DispatchMaster.objects.using(self.compas).create(code=u'%s%sP'%(self.compas, waybill.pk[len(self.compas):]), + document_code='AB', + dispatch_date=datetime.now(), + origin_type='B', + origin_location_code='ukraine', + destination_code='ISBX003') send_received(waybill, self.compas) self.assertTrue(ets.models.Waybill.objects.get(pk="ISBX00312A").receipt_sent_compas) @@ -179,11 +187,13 @@ def call_db_procedure(name, parameters, using): receipt_signed_date=datetime.now()) #Send all validated waybills to compas + send_received(ets.models.Waybill.objects.get(pk="ISBX00312A"), self.compas) self.assertFalse(ets.models.Waybill.objects.get(pk="ISBX00312A").receipt_sent_compas) self.assertFalse(ets.models.Waybill.objects.get(pk="ISBX00312A").receipt_validated) #Check compass logger logger = ets.models.CompasLogger.objects.get(waybill__pk='ISBX00312A') - self.assertTupleEqual((logger.status, logger.message), (ets.models.CompasLogger.FAILURE, "Test wrong message")) + #self.assertTupleEqual((logger.status, logger.message), (ets.models.CompasLogger.FAILURE, "Test wrong message")) + self.assertTupleEqual((logger.status, logger.message), (ets.models.CompasLogger.FAILURE, "The Dispatch ISBX00312A is not available in the COMPAS Station ISBX002")) diff --git a/src/ets/tests/test_waybill.py b/src/ets/tests/test_waybill.py index 301a0bba..ad773860 100644 --- a/src/ets/tests/test_waybill.py +++ b/src/ets/tests/test_waybill.py @@ -149,7 +149,7 @@ def test_create_waybill(self): } response = self.client.post(reverse('waybill_create', kwargs={'order_pk': self.order.pk,}), data=data) - self.assertContains(response, u'Chose Destination Warehouse or another Transaction Type') + self.assertContains(response, u'Choose Destination Warehouse or another Transaction Type') self.assertContains(response, u'Overloaded for 10.250 tons') data.update({ @@ -514,14 +514,13 @@ def test_waybill_reception_scanned(self): 'distance': 5, 'receipt_remarks': 'test remarks', 'destination': 'OE7X001', + 'receipt_warehouse': 'OE7X001', } response = self.client.post(reverse('waybill_reception_scanned', kwargs={'scanned_code': data,}), data=form_data) - way = ets.models.Waybill.objects.get(pk=waybill_pk) # Everything should be fine - self.assertRedirects(response, way.get_absolute_url()) self.assertEqual(ets.models.Waybill.objects.get(pk=waybill_pk).receipt_remarks, 'test remarks') data = "-123143" diff --git a/src/ets/tests/utils.py b/src/ets/tests/utils.py index a091f094..b6adbd5d 100644 --- a/src/ets/tests/utils.py +++ b/src/ets/tests/utils.py @@ -5,7 +5,7 @@ from django.conf import settings from django.core.management import call_command -from ets.models import Compas +from ets.models import Compas, CommodityCategory def change_settings(func, **kwargs): @wraps(func) @@ -28,14 +28,17 @@ class TestCaseMixin(object): #multi_db = True compas = 'ISBX002' - fixtures = ('db_compas.json', 'warehouse.json', 'groups.json', 'permissions.json') + fixtures = ('db_compas.json', 'groups.json', 'permissions.json', 'warehouse.json') def setUp(self): "Hook method for setting up the test fixture before exercising it." - + for cat in CommodityCategory.objects.all(): + print cat.code call_command('loaddata', 'compas.json', verbosity=0, commit=False, database=self.compas) station = Compas.objects.get(pk=self.compas) station.update(base=True) station.update(base=False) call_command('loaddata', 'development.json', verbosity=0, commit=False, database='default') + + diff --git a/src/ets/utils.py b/src/ets/utils.py index b4c6584f..534e126c 100644 --- a/src/ets/utils.py +++ b/src/ets/utils.py @@ -447,7 +447,6 @@ def send_dispatched(waybill, compas=None, cache_prefix='send_dispatched'): ), compas) except Exception, err: - message = hasattr(err, 'messages') and u"\n".join(err.messages) or unicode(err) for error_message in reduce_compas_errors(message): ets_models.CompasLogger.objects.create(action=ets_models.CompasLogger.DISPATCH, diff --git a/src/ets/views.py b/src/ets/views.py index acf68d77..a1beae86 100644 --- a/src/ets/views.py +++ b/src/ets/views.py @@ -421,9 +421,10 @@ def waybill_reception(request, waybill_pk, queryset, form_class=WaybillRecieptFo def waybill_reception_scanned(request, scanned_code, queryset): """Special view that accepts scanned data^ deserialized and redirect to waybill_receiption of that waybill""" waybill = ets.models.Waybill.decompress(scanned_code) - + if not waybill: raise Http404 + print 'waybill_reception' return waybill_reception(request, waybill.pk, queryset) @dispatcher_required