Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def read(fname):
#Dependencies - python eggs
install_requires = [
'setuptools',
'Django==1.3.3',
'Django >= 1.4',
#'httplib2',
'south',
'django-rosetta',
Expand Down
12 changes: 11 additions & 1 deletion src/ets/fixtures/compas.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -422,7 +432,7 @@
}
},
{
"pk": "ISBX00312A",
"pk": "ISBX00312AP",
"model": "compas.dispatchmaster",
"fields": {
"document_code": "AB",
Expand Down
1 change: 1 addition & 0 deletions src/ets/fixtures/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
30 changes: 30 additions & 0 deletions src/ets/fixtures/warehouse.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
]
18 changes: 14 additions & 4 deletions src/ets/tests/test_compas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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"))

5 changes: 2 additions & 3 deletions src/ets/tests/test_waybill.py
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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"
Expand Down
9 changes: 6 additions & 3 deletions src/ets/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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')


1 change: 0 additions & 1 deletion src/ets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/ets/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down