Exemplo n.º 1
0
def search(request):
	result = []
	search_string = request.GET.get("searchString","")
	result = plugins.searchStringValid(search_string)
	if result["code"] == 0:
		#return HttpResponse(json.dumps(result), content_type="application/json")
		request.session["error_message"] = ""
		return render_to_response('searchResult.html',{"searchString":search_string})
	else:
		#return HttpResponse(json.dumps(result), content_type="application/json")
		request.session["error_message"] = result["message"]
		#return HttpResponseRedirect('/?message=inputError')
		return HttpResponseRedirect('/')
Exemplo n.º 2
0
    def test_searchStringValid(self):
        self.logger.info("Index Search String Valid Test")
        for string_set in self.string_set_list:
            for s in string_set["set_data_list"]:
                result = plugins.searchStringValid(s)
                log_info = "{} - {} - {}".format(result["code"],
                                                 string_set["set_return_code"],
                                                 result["message"])
                self.logger.info(log_info)
                '''
				if result["code"]==string_set["set_return_code"]:
					print "{} - {} - {}".format(result["code"], string_set["set_return_code"], result["message"])
				else:
					print "Oh, No!!!"
				'''
                self.assertEqual(result["code"], string_set["set_return_code"])