Rev 4642 | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 13-Sep-2010@author: rajveer'''import osimport syssys.path.insert(0, os.getcwd())from shop2020.clients.LogisticsClient import LogisticsClientfrom shop2020.thriftpy.logistics.ttypes import DeliveryTypeimport datetime"""now = datetime.datetime.now()test = now.hourprint test, now.houritemlogistics = client.getLogisticsEstimation(1, "332301")print itemlogistics.warehouseIdprint itemlogistics.availabilityprint itemlogistics.shippingTime""""""The following test cases are to test if correct provider is being returned. For a destination pincode and a warehouse,the provider mapping is defined in PyProj/src/samplesheets/Courier_Logic.xlsTo check the output make modifications in the following function to print provider on the console.PyProj/src/shop2020/logistics/service/impl/DataAccessor/get_logistics_estimation"""# Item = 14 (<5000) Pincode = 125005 (Non-Local) serviced by Both, Provider = 1# Item = 02 (>5000) Pincode = 125005 (Non-Local) serviced by Both, Provider = 1# Item = 19 (=5000) Pincode = 123106 (Non-Local) serviced by AFL, Provider = 2# Item = 01 (>5000) Pincode = 123106 (Non-Local) serviced by AFL, Provider = 2# Item = 14 (<5000) Pincode = 834011 (Non-Local) serviced by AFL, Provider = 2# Item = 14 (<5000) Pincode = 854305 (Non-Local) serviced by BlueDart, Provider = 1# Item = 01 (>5000) Pincode = 854305 (Non-Local) serviced by BlueDart, Provider = 1# Item = 03 (>5000) Pincode = 201301 (Local) serviced by Both, Provider = 1# Item = 15 (<5000) Pincode = 201301 (Local) serviced by Both, Provider = 2# Item = 04 (>5000) Pincode = 201307 (Local) serviced by Both, Provider = 1# Item = 19 (=5000) Pincode = 201307 (Local) serviced by Both, Provider = 2def adjust_delivery_time(start_time, delivery_days):'''Returns the actual no. of days which will pass while 'delivery_days'no. of business days will pass since 'order_time'.'''start_date = start_time.date()end_date = start_date + datetime.timedelta(days = delivery_days)while start_date <= end_date:if start_date.weekday() == 6:delivery_days = delivery_days + 1end_date = end_date + datetime.timedelta(days = 1)start_date = start_date + datetime.timedelta(days = 1)return delivery_days#print client.getEmptyAWB(1)#print client.getLogisticsEstimation(14, "201301", DeliveryType.PREPAID) #Provider = 1starttime = datetime.datetime.now()for j in range(5):client = LogisticsClient().get_client()for i in range(200):try:print client.getLogisticsEstimation(i, "201301", DeliveryType.PREPAID) #Provider = 1print client.getLogisticsEstimation(i, "201301", DeliveryType.COD) #Provider = 1print client.getLogisticsEstimation(i, "332001", DeliveryType.PREPAID) #Provider = 1print client.getLogisticsEstimation(i, "332001", DeliveryType.COD) #Provider = 1except:print "exception"endtime = datetime.datetime.now()print endtime, starttime#print client.getLogisticsEstimation(26, "201301", DeliveryType.PREPAID) #Provider = 1#print client.getLogisticsEstimation(15, "201301", DeliveryType.PREPAID) #Provider = 1#print client.getLogisticsEstimation(16, "110001", DeliveryType.PREPAID) #Provider = 1#print client.getLogisticsEstimation(17, "332001", DeliveryType.PREPAID) #Provider = 1#logistics_info = client.getLogisticsInfo("201301", 15, DeliveryType.PREPAID)#current_time = datetime.datetime.now()#print adjust_delivery_time(current_time, logistics_info.deliveryTime)#print adjust_delivery_time(current_time, logistics_info.shippingTime)#print (current_time + datetime.timedelta(days=logistics_info.shippingTime)).replace(hour=12, minute=0, second=0)#print current_time + datetime.timedelta(days=logistics_info.deliveryTime)#print client.isCodAllowed("201301")#print client.isCodAllowed("3")#print client.getDestinationCode(1, "201301")#print client.getDestinationCode(1, "332001")#client.getLogisticsEstimation(02, "125005") #Provider = 1#client.getLogisticsEstimation(19, "123106") #Provider = 2#client.getLogisticsEstimation(01, "123106") #Provider = 2#client.getLogisticsEstimation(14, "834011") #Provider = 2#client.getLogisticsEstimation(14, "854305") #Provider = 1#client.getLogisticsEstimation(1, "854305") #Provider = 1##client.getLogisticsEstimation(03, "201301") #Provider = 1#client.getLogisticsEstimation(15, "201301") #Provider = 2#client.getLogisticsEstimation(04, "201307") #Provider = 1#client.getLogisticsEstimation(19, "201307") #Provider = 2