Subversion Repositories SmartDukaan

Rev

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

Rev 2251 Rev 2304
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
    VendorItemPricing
3
import datetime
3
import datetime
-
 
4
import os
-
 
5
from time import strftime
4
from shop2020.clients.InventoryClient import InventoryClient
6
from shop2020.clients.InventoryClient import InventoryClient
5
from shop2020.utils.Utils import to_java_date, to_py_date
7
from shop2020.utils.Utils import to_java_date, to_py_date
6
from shop2020.model.v1.catalog.impl.DataAcessors import validate_item_prices, validate_vendor_prices
8
from shop2020.model.v1.catalog.impl.DataAcessors import validate_item_prices, validate_vendor_prices
7
 
9
 
8
 
10
 
Line 71... Line 73...
71
#        print ex
73
#        print ex
72
#        return
74
#        return
73
#    print 'prices validated'
75
#    print 'prices validated'
74
    return
76
    return
75
 
77
 
76
def check_similar_item():
78
def test_similar_item():
77
    print (client.checkSimilarItem('handset', 'spice', 'bldk', None))
79
    print (client.checkSimilarItem('handset', 'spice', 'bldk', None))
78
    print (client.checkSimilarItem('handset', 'spice', 'bldk', ''))
80
    print (client.checkSimilarItem('handset', 'spice', 'bldk', ''))
79
    print (client.checkSimilarItem('handset', 'spice', 'bldk', 'Black'))
81
    print (client.checkSimilarItem('handset', 'spice', 'bldk', 'Black'))
80
 
82
 
81
if __name__ == '__main__':
-
 
82
    time = to_py_date(datetime.datetime.now())
-
 
83
    #test_validate()
83
def test_change_item_status():
84
    #check_similar_item()
-
 
85
    
-
 
86
    #changeItemStatus method testing
84
    #changeItemStatus method testing
87
    """
-
 
88
    client.changeItemStatus(1, time, status.PAUSED)
85
    client.changeItemStatus(1, time, status.PAUSED)
89
    item = client.getItem(1)
86
    item = client.getItem(1)
90
    print 'item status = ' + str(item.itemStatus) + ", desc = " + item.status_description
87
    print 'item status = ' + str(item.itemStatus) + ", desc = " + item.status_description
91
    
88
    
92
    client.changeItemStatus(1, time, status.PHASED_OUT)
89
    client.changeItemStatus(1, time, status.PHASED_OUT)
93
    item = client.getItem(1)
90
    item = client.getItem(1)
94
    print 'item status = ' + str(item.itemStatus) + ", desc = " + item.status_description
91
    print 'item status = ' + str(item.itemStatus) + ", desc = " + item.status_description
95
    """
-
 
96
    
92
 
-
 
93
def test_check_risky_item():
97
    #mark_risky_item method testing. It is called from the following 3 methods.
94
    #mark_risky_item method testing. It is called from the following 3 methods.
98
    """
-
 
99
    availability = {"battery|nokia|bl 4b|na":-1}
95
    availability = {"battery|nokia|bl 4b|na":-1}
100
    client.updateInventory(2, time, availability)
96
    client.updateInventory(2, time, availability)
101
    
-
 
102
    client.reserveItemInWarehouse(167, 2, 1)
97
    client.reserveItemInWarehouse(167, 2, 1)
103
    """
-
 
104
    client.reduceReservationCount(167, 2, 1)
98
    client.reduceReservationCount(167, 2, 1)
-
 
99
 
-
 
100
 
-
 
101
def test_logging(item_id, risky):
-
 
102
    logfile = open(os.getenv("HOME")+'/'+'riskyNew.log', 'a')
-
 
103
    logfile.write(str(strftime("%Y-%m-%d %H:%M:%S")) + ', ItemId=' + str(item_id) + ', ' + str(risky) + '\n')
-
 
104
 
-
 
105
if __name__ == '__main__':
-
 
106
    time = to_py_date(datetime.datetime.now())
-
 
107
    #test_validate()
-
 
108
    #test_similar_item()
-
 
109
    #test_change_item_status()
-
 
110
    #test_check_risky_item()
-
 
111
    #test_logging(5, True)
-
 
112
    
105
    
113
    
106
    
114
    
107
    
115
    
108
116