def explore(): with open("pickle/" + session["passenger"] + ".pickle", "rb") as f: passenger = pickle.load(f) arr_gate, dest_gate = passenger.get_arrival_gate( ), passenger.get_dest_gate() arr_time, dest_time = arr_gate["time"], dest_gate["time"] arr_gate["time"] = arr_time.strftime("%H:%M") dest_gate["time"] = dest_time.strftime("%H:%M") r = Recommender(demo=True) recs = r.recommendations() print recs s = Shopping(recs) top_list = s.get_list(5) print top_list data = { "arrival": arr_gate, "destination": dest_gate, "objects": helper(passenger), "shopping": top_list } print json.dumps(data, indent=4) return render_template("explore.html", data=data)
def test_0newlistnameless(self): test=Shopping().newlist jsonInput = {'from': u'Lisa-Web', 'zone': u'WebSocket', u'msg_id': u'c7e169a5-9d87-4a43-8a11-9fa75fd0e5ae', u'msg_body': u'do new list without name', u'outcome': { u'entities': {}, u'confidence': 0.585, u'intent': u'shopping_newlist'}, 'type': u'chat'} ret = test(jsonInput) try : assert (ret['test'] == 'no-name') except AssertionError : print ret["body"] raise AssertionError
def test_1getlist(self): test=Shopping().getlist jsonInput = {'from': u'Lisa-Web', 'zone': u'WebSocket', u'msg_id': u'c7e169a5-9d87-4a43-8a11-9fa75fd0e5ae', u'msg_body': u'which list have I', u'outcome': { u'entities': { u'confidence': 0.999, u'intent': u'shopping_getlist'}, 'type': u'chat'}} ret = test(jsonInput) try : assert (ret['test'] == 'no-existing') except AssertionError : print ret['test'] print ret["body"] raise AssertionError
def test_0newlistagain(self): test=Shopping().newlist jsonInput = {'from': u'Lisa-Web', 'zone': u'WebSocket', u'msg_id': u'c7e169a5-9d87-4a43-8a11-9fa75fd0e5ae', u'msg_body': u'do the same new list for test', u'outcome': { u'entities': { u'message_subject': {u'body': u'les courses', u'start': 30, u'end': 41, u'suggested': True, u'value': u'test'}}, u'confidence': 0.585, u'intent': u'shopping_newlist'}, 'type': u'chat'} ret = test(jsonInput) try : assert (ret['test'] == 'duplicate') except AssertionError : print ret["body"] raise AssertionError
def test_4deleteNoList(self): test=Shopping().deletelist jsonInput = {'from': u'Lisa-Web', 'zone': u'WebSocket', u'msg_id': u'97c99d41-37d9-4811-95e0-6a5c89d7e1ad', u'msg_body': u'add an item for test', u'outcome': { u'entities': { }, u'confidence': 0.963, u'intent': u'shopping_add' }, 'type': u'chat'} ret = test(jsonInput) try : assert (ret['test'] == 'no-namelist') except AssertionError : print ret["body"] raise AssertionError
def test_4deleteNoExisitingList(self): test=Shopping().deletelist jsonInput = {'from': u'Lisa-Web', 'zone': u'WebSocket', u'msg_id': u'97c99d41-37d9-4811-95e0-6a5c89d7e1ad', u'msg_body': u'add an item for test', u'outcome': { u'entities': { u'message_subject': {u'body': u'where ?', u'start': 40, u'end': 60, u'suggested': True, u'value': u'test'} }, u'confidence': 0.963, u'intent': u'shopping_add' }, 'type': u'chat'} ret = test(jsonInput) try : assert (ret['test'] == 'no-existing') except AssertionError : print ret["body"] raise AssertionError
def test_2addNoList(self): test=Shopping().add jsonInput = {'from': u'Lisa-Web', 'zone': u'WebSocket', u'msg_id': u'97c99d41-37d9-4811-95e0-6a5c89d7e1ad', u'msg_body': u'add an item for test', u'outcome': { u'entities': { u'shopping_item': {u'body': u'what ?', u'start': 12, u'end': 24, u'suggested': True, u'value': u'item'}, u'number': {u'body': u'how ?', u'start': 8, u'end': 11, u'value': 2} }, u'confidence': 0.963, u'intent': u'shopping_add' }, 'type': u'chat'} ret = test(jsonInput) try : assert (ret['test'] == 'no-list') except AssertionError : print ret["body"] raise AssertionError
from shopping import Shopping import random if __name__ == "__main__": print(random) s1 = Shopping('Apple','Banana') print(s1.showBuys()) print(s1.delete('Apple')) print(s1.showBuys())