def test_get_matching_arr4(self): list1 = ["a", "b", "c", "d"] list2 = [] result = sorted(dut.getMatchingArr(list1, list2)) expected = [] assert result == expected
def test_get_matching_arr5(self): list1 = "notOCR" list2 = ["F", "E", "D", "E", "D", "C", "B", "A"] result = dut.getMatchingArr(list1, list2) expected = "notOCR" print(result) assert result == expected
def test_get_matching_arr2(self): list1 = ["a", "b", "c", "d"] list2 = ["F", "E", "D", "E", "D", "C", "B", "A"] result = sorted(dut.getMatchingArr(list1, list2)) expected = ["a", "b", "c", "d"] assert result == expected
def CheckHarmfulOCR(self): if self.noImg(): return responseOCR = googleVision.requestOCR(objectImg) harmfulList = database.Get_Harmful_List() matchingArr = googleVision.getMatchingArr(responseOCR, harmfulList) self.printIntersection("generally harmful ingredients", matchingArr)
def CheckIngredientsRecognition(self, username): if self.noImg(): return tags_array = googleVision.requestRecognition(objectImg) ingredients_array = database.Get_Custom_Ingredients(tags_array) self.subcanvas = tk.Canvas(app.canvas, height=100000000) self.subcanvas.pack(padx=(50, 50), pady=(550, 0)) # create list of all the custom items relevant to the item # create buttons that can display these lists with printIngredients() max = 0 for i in range(0, len(tags_array)): # Rows if ingredients_array[i] != '0': ahoy = partial(self.printIngredients, self.subcanvas, ingredients_array[i], i) self.itemList[i] = tk.Button(self.subcanvas, text=tags_array[i], borderwidth=2, relief="solid", height=2, font=('helvetica', 15), command=ahoy) self.itemList[i].grid(row=i, column=0, padx=10, sticky="W") if self.itemList[i].winfo_width() > max: max = self.itemList[i].winfo_width() userList = database.Get_Personal_List(username) # get the matching array matchingArr = googleVision.getMatchingArr(ingredients_array, userList) self.printIntersection("ingredients matching your personal list", matchingArr)
def CheckIngredientsOCR(self, username): if self.noImg(): return responseOCR = googleVision.requestOCR(objectImg) userList = database.Get_Personal_List(username) matchingArr = googleVision.getMatchingArr(responseOCR, userList) self.printIntersection("ingredients matching your personal list", matchingArr)
def CheckHarmfulRecognition(self): if self.noImg(): return responseRec = googleVision.requestRecognition(objectImg) responseRec = database.Get_Custom_Ingredients(responseRec) harmfulList = database.Get_Harmful_List() matchingArr = googleVision.getMatchingArr(responseRec, harmfulList) self.printIntersection("generally harmful ingredients", matchingArr)
def test_get_matching_arr6(self): list1 = "notRecognition" list2 = ["F", "E", "D", "E", "D", "C", "B", "A"] result = dut.getMatchingArr(list1, list2) expected = "notRecognition" assert result == expected # # class RequestOCRTest(TestCase): # # # def requestOCR(img_path): # img_data = prepareRequest(img_path, 'TEXT_DETECTION', 1) # response = requests.post(url, # data=img_data, # params={'key': key}, # headers={'Content-Type': 'application/json'}) # try: # response = response.json()["responses"][0]["textAnnotations"][0]["description"].lower() # return response # except KeyError: # return "notOCR"
def test_get_matching_arr0(self): list1 = ["apple", "banana", "orange", "grape"] list2 = ["red", "orange", "yellow", "green"] result = sorted(dut.getMatchingArr(list1, list2)) assert result == ["orange"]