Subversion Repositories SmartDukaan

Rev

Rev 2207 | Rev 2251 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2065 ankur.sing 1
from shop2020.thriftpy.model.v1.catalog.ttypes import Item, status, Warehouse,\
2
    VendorItemPricing
122 ashish 3
import datetime
384 ashish 4
from shop2020.clients.InventoryClient import InventoryClient
122 ashish 5
from shop2020.utils.Utils import to_java_date
2207 ankur.sing 6
from shop2020.model.v1.catalog.impl.DataAcessors import validate_item_prices, validate_vendor_prices
100 ashish 7
 
2207 ankur.sing 8
 
384 ashish 9
inventory_client = InventoryClient()
10
 
11
inventory_client.__start__()
12
 
13
client = inventory_client.get_client()
2207 ankur.sing 14
"""
1506 chandransh 15
#deals = client.getBestDeals()
16
#print deals
384 ashish 17
 
1506 chandransh 18
warehouse_id, items_in_inventory = client.getItemAvailabilityAtLocation(0, 132)
19
print warehouse_id
2065 ankur.sing 20
print items_in_inventory
21
"""
22
 
23
 
24
def test_validate():
25
    # Item prices should follow the following validations.
26
    # mrp > sellingPrice
27
    # mrp > mop
28
    # xferPrice < mop
29
 
30
    item = Item()
31
    item.id = 1
32
    item.productGroup = "Handsets"
33
    item.modelNumber = "MI-310"
34
    item.brand = "Spice"
35
    item.color = "Red"
36
 
37
    vip = VendorItemPricing()
38
    vip.vendorId = 1
39
 
40
    set_prices1(item, vip)
41
    set_prices2(item, vip)
42
    return
43
 
44
def set_prices1(item, vip):
45
    #Test Case 1 (mrp < sellingPrice)
46
    item.mrp = 220.50
47
    item.sellingPrice = 225.50
48
 
49
    vip.mop = 111
50
    vip.dealerPrice = 111
51
    vip.transferPrice = 111
52
    validate(item,vip)
53
    return
54
 
55
def set_prices2(item, vip):
56
    #Test Case 2 (mrp < mop)
57
    item.mrp = 230.50
58
    item.sellingPrice = 225.50
59
 
60
    vip.mop = 235.0
61
    vip.dealerPrice = 210.0
62
    vip.transferPrice = 200.5
63
    validate(item,vip)
64
    return
65
 
66
 
67
def validate(item, vip):
2222 chandransh 68
#    try:
69
#        #validate_prices(item, vip)
70
#    except Exception as ex:
71
#        print ex
72
#        return
73
#    print 'prices validated'
2065 ankur.sing 74
    return
75
 
2207 ankur.sing 76
def check_similar_item():
77
    print (client.checkSimilarItem('handset', 'spice', 'bldk', None))
78
    print (client.checkSimilarItem('handset', 'spice', 'bldk', ''))
79
    print (client.checkSimilarItem('handset', 'spice', 'bldk', 'Black'))
80
 
2065 ankur.sing 81
if __name__ == '__main__':
2207 ankur.sing 82
    #test_validate()
83
    check_similar_item()