Subversion Repositories SmartDukaan

Rev

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