Subversion Repositories SmartDukaan

Rev

Rev 494 | Rev 3218 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 494 Rev 1504
Line 7... Line 7...
7
from shop2020.clients.LogisticsClient import LogisticsClient
7
from shop2020.clients.LogisticsClient import LogisticsClient
8
from shop2020.thriftpy.logistics.ttypes import *
8
from shop2020.thriftpy.logistics.ttypes import *
9
import datetime
9
import datetime
10
 
10
 
11
 
11
 
12
logistic_client = LogisticsClient()
-
 
13
 
-
 
14
logistic_client.__start__()
-
 
15
 
-
 
16
client = logistic_client.get_client()
12
client = LogisticsClient().get_client()
17
 
-
 
18
#client.addPincodeWarehouseMapping("332301", 1, "303030")
-
 
19
 
-
 
20
#client.addDeliveryEstimate(1, "332301", 1, 3, 80)
-
 
21
 
13
 
-
 
14
"""
22
now = datetime.datetime.now()
15
now = datetime.datetime.now()
23
 
-
 
24
test = now.hour
16
test = now.hour
25
print test, now.hour
17
print test, now.hour
26
itemlogistics = client.getLogisticsEstimation(1, "332301", 1)
18
itemlogistics = client.getLogisticsEstimation(1, "332301")
27
print itemlogistics.warehouseId
19
print itemlogistics.warehouseId
28
print itemlogistics.availability
20
print itemlogistics.availability
29
print itemlogistics.shippingTime
21
print itemlogistics.shippingTime
-
 
22
"""
30
 
23
 
31
 
24
 
32
 
-
 
33
    
-
 
34
    
-
 
35
"""    
-
 
36
numbers =  ["129102","121823","138123"]
-
 
37
provider_id = 1
-
 
38
 
-
 
39
 
-
 
40
client.addEmptyAWBs(numbers, provider_id)
-
 
41
awb = client.getEmptyAWB(provider_id)
-
 
42
print awb
-
 
43
 
-
 
44
provider = client.getProvider(provider_id)
-
 
45
print provider.id
-
 
46
print provider.name
-
 
47
 
-
 
48
providers = []
-
 
49
providers = client.getProviders()
-
 
50
for prov in providers:
-
 
51
    print prov.id
-
 
52
    print prov.name
-
 
53
 
-
 
54
   
-
 
55
shipment = Shipment()
-
 
56
shipment.awb = awb
-
 
57
shipment.destination = "Jaipur"
-
 
58
shipment.origin = "Delhi"
-
 
59
shipment.recepient_address = "Malviya Nagar, Delhi"
-
 
60
shipment.recepient_name = "Rajveer"
-
 
61
shipment.recepient_phone = "985983524"
-
 
62
shipment.recepient_pincode = "1727123"
-
 
63
shipment.shipment_contents = "Mobile Phone"
-
 
64
shipment.shipment_weight = "10 KGs"
-
 
65
shipment.warehouse_name = "Noida Warehouse"
-
 
66
#shipment.timestamp = datetime.datetime.today()
-
 
67
client.createShipment(shipment)
-
 
68
 
-
 
69
shipment_update = ShipmentUpdate()
-
 
70
shipment_update.pin = "912313123"
-
 
71
shipment_update.description = "On Delhi airport"
-
 
72
#shipment_update.timestamp = datetime.datetime.today()
-
 
73
client.updateShipmentStatus(awb, shipment_update)
-
 
74
 
-
 
75
 
-
 
76
shipment_status_info = client.getShipmentInfo(awb)
-
 
77
print shipment_status_info.awb
-
 
78
print shipment_status_info.provider_id
-
 
79
print shipment_status_info.currentUpdate.pin
-
 
80
print shipment_status_info.currentUpdate.description
-
 
81
print shipment_status_info.currentUpdate.timestamp
-
 
82
 
-
 
83
#shipments = client.getShipments(1, datetime.datetime.today(), datetime.datetime.today(), provider_id)
-
 
84
 
-
 
85
shipments = client.getTodaysShipments(1, provider_id)
-
 
86
 
-
 
87
for shipment in shipments:
-
 
88
    print shipment.recepient_address
-
 
89
    print shipment.recepient_name
-
 
90
    print shipment.recepient_pincode
-
 
91
    print shipment.shipment_contents
-
 
92
    print shipment.shipment_weight
-
 
93
    print shipment.warehouse_name
-
 
94
    print shipment.recepient_phone
-
 
95
    print shipment.origin
-
 
96
    print shipment.destination
-
 
97
    print shipment.awb
-
 
98
    
-
 
99
"""
-
 
100
25
"""
-
 
26
The following test cases are to test if correct provider is being returned. For a destination pincode and a warehouse,
-
 
27
the provider mapping is defined in PyProj/src/samplesheets/Courier_Logic.xls
-
 
28
To check the output make modifications in the following function to print provider on the console.
-
 
29
PyProj/src/shop2020/logistics/service/impl/DataAccessor/get_logistics_estimation
-
 
30
"""
-
 
31
 
-
 
32
# Item = 14 (<5000) Pincode = 125005 (Non-Local) serviced by Both, Provider = 1
-
 
33
# Item = 02 (>5000) Pincode = 125005 (Non-Local) serviced by Both, Provider = 1
-
 
34
# Item = 19 (=5000) Pincode = 123106 (Non-Local) serviced by AFL,  Provider = 2
-
 
35
# Item = 01 (>5000) Pincode = 123106 (Non-Local) serviced by AFL,  Provider = 2
-
 
36
# Item = 14 (<5000) Pincode = 834011 (Non-Local) serviced by AFL,  Provider = 2
-
 
37
# Item = 14 (<5000) Pincode = 854305 (Non-Local) serviced by BlueDart,  Provider = 1
-
 
38
# Item = 01 (>5000) Pincode = 854305 (Non-Local) serviced by BlueDart,  Provider = 1
-
 
39
 
-
 
40
# Item = 03 (>5000) Pincode = 201301 (Local) serviced by Both, Provider = 1
-
 
41
# Item = 15 (<5000) Pincode = 201301 (Local) serviced by Both, Provider = 2
-
 
42
# Item = 04 (>5000) Pincode = 201307 (Local) serviced by Both,  Provider = 1
-
 
43
# Item = 19 (=5000) Pincode = 201307 (Local) serviced by Both,  Provider = 2
-
 
44
 
-
 
45
 
-
 
46
client.getLogisticsEstimation(14, "125005") #Provider = 1
-
 
47
client.getLogisticsEstimation(02, "125005") #Provider = 1
-
 
48
client.getLogisticsEstimation(19, "123106") #Provider = 2
-
 
49
client.getLogisticsEstimation(01, "123106") #Provider = 2
-
 
50
client.getLogisticsEstimation(14, "834011") #Provider = 2
-
 
51
client.getLogisticsEstimation(14, "854305") #Provider = 1
-
 
52
client.getLogisticsEstimation(1, "854305") #Provider = 1
-
 
53
 
-
 
54
client.getLogisticsEstimation(03, "201301") #Provider = 1
-
 
55
client.getLogisticsEstimation(15, "201301") #Provider = 2
-
 
56
client.getLogisticsEstimation(04, "201307") #Provider = 1
-
 
57
client.getLogisticsEstimation(19, "201307") #Provider = 2
-
 
58