Subversion Repositories SmartDukaan

Rev

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

Rev 1506 Rev 2065
Line 1... Line 1...
1
from shop2020.thriftpy.model.v1.catalog.ttypes import Item, status, Warehouse
1
from shop2020.thriftpy.model.v1.catalog.ttypes import Item, status, Warehouse,\
-
 
2
    VendorItemPricing
2
import datetime
3
import datetime
3
from shop2020.clients.InventoryClient import InventoryClient
4
from shop2020.clients.InventoryClient import InventoryClient
4
from shop2020.utils.Utils import to_java_date
5
from shop2020.utils.Utils import to_java_date
-
 
6
from shop2020.model.v1.catalog.impl.DataAcessors import validate_prices
5
 
7
 
-
 
8
"""
6
inventory_client = InventoryClient()
9
inventory_client = InventoryClient()
7
 
10
 
8
inventory_client.__start__()
11
inventory_client.__start__()
9
 
12
 
10
client = inventory_client.get_client()
13
client = inventory_client.get_client()
11
#deals = client.getBestDeals()
14
#deals = client.getBestDeals()
12
#print deals
15
#print deals
13
 
16
 
14
warehouse_id, items_in_inventory = client.getItemAvailabilityAtLocation(0, 132)
17
warehouse_id, items_in_inventory = client.getItemAvailabilityAtLocation(0, 132)
15
print warehouse_id
18
print warehouse_id
16
print items_in_inventory
-
 
17
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()
-
 
77