def test_rpc_search_drink_price(): # Search for tequila type = "Tequila" result = db.cost_search_drink_type(type) found = False # Check for Tequila for (t, a, b, c, d, e, f) in result: if t == "TEQUILA": found = True break assert found
def recv_search_drink_price(self, environ, start_response): formdata = environ['QUERY_STRING'] results = urlparse.parse_qs(formdata) search_results = set() #Check if values have data if ('type' in results): #Get type type = results['type'][0] #Search for given type search_results = db.cost_search_drink_type(type) message = "Search results for: " + type #Empty field else: message = "Ooops no value was entered, please try again" #Generate results in html format content_type = 'text/html' data= """ <html> <head> <title>Results of liquor prices</title> <style type='text/css'> h1 {color:red;} body{ font-size:14px; } </style> </head> <body> """ data = data + "<h1>" + message + "</h1>" tmp = dynamic_web.generate_drink_cost_table(search_results) data = data + tmp data = data + "<p><a href='./search_drink_price.html'>Search for another drink</a></p>" data = data + "<p><a href='./'>return to index</a></p>" data = data + """ </body> <html> """ start_response('200 OK', list(html_headers)) return [data]
def rpc_search_drink_price(self, type): return db.cost_search_drink_type(type)