From 51ce4b12785c9c873f5e73ed8b821d6b49826194 Mon Sep 17 00:00:00 2001 From: Luis Remis Date: Fri, 29 Mar 2019 09:59:43 -0700 Subject: [PATCH] Add more testing for FindDesc --- tests/python/TestFindDescriptors.py | 82 ++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/tests/python/TestFindDescriptors.py b/tests/python/TestFindDescriptors.py index 48240b92..d23ad63d 100644 --- a/tests/python/TestFindDescriptors.py +++ b/tests/python/TestFindDescriptors.py @@ -193,6 +193,86 @@ def test_findDescByConst_get_id(self): self.assertEqual(response[0]["FindDescriptor"] ["entities"][0]["myid"], 205) + def test_findDescByConst_blobTrue(self): + + # Add Set + set_name = "features_128d_4_findDescriptors_id_blob" + dims = 128 + total = 100 + self.create_set_and_insert(set_name, dims, total) + + db = self.create_connection() + + all_queries = [] + + finddescriptor = {} + finddescriptor["set"] = set_name + + constraints = {} + constraints["myid"] = ["==", 205] + finddescriptor["constraints"] = constraints + + results = {} + results["list"] = ["myid", "_label", "_id"] + results["blob"] = True + finddescriptor["results"] = results + + query = {} + query["FindDescriptor"] = finddescriptor + + all_queries = [] + all_queries.append(query) + + response, fv_array = db.query(all_queries) + + # Check success + self.assertEqual(response[0]["FindDescriptor"]["status"], 0) + self.assertEqual(response[0]["FindDescriptor"]["returned"], 1) + self.assertEqual(response[0]["FindDescriptor"] + ["entities"][0]["myid"], 205) + self.assertEqual(len(fv_array), 1) + self.assertEqual(len(fv_array[0]), dims*4) + + def test_findDescByConst_multiple_blobTrue(self): + + # Add Set + set_name = "features_128d_4_findDescriptors_m_blob" + dims = 128 + total = 100 + self.create_set_and_insert(set_name, dims, total) + + db = self.create_connection() + + all_queries = [] + + finddescriptor = {} + finddescriptor["set"] = set_name + + constraints = {} + constraints["myid"] = ["<=", 205] + finddescriptor["constraints"] = constraints + + results = {} + results["list"] = ["myid"] + results["blob"] = True + finddescriptor["results"] = results + + query = {} + query["FindDescriptor"] = finddescriptor + + all_queries = [] + all_queries.append(query) + + response, fv_array = db.query(all_queries) + + # Check success + self.assertEqual(response[0]["FindDescriptor"]["status"], 0) + self.assertEqual(response[0]["FindDescriptor"]["returned"], 6) + self.assertEqual(response[0]["FindDescriptor"] + ["entities"][5]["myid"], 200) + self.assertEqual(len(fv_array), 6) + self.assertEqual(len(fv_array[0]), dims*4) + def test_findDescByBlob(self): # Add Set @@ -416,7 +496,6 @@ def test_findDescByBlobUnusedRef(self): # descriptor_blob.append(x.tobytes()) # response, blob_array = db.query(all_queries, [descriptor_blob]) - # print(db.get_last_response_str()) # self.assertEqual(len(blob_array), kn) # self.assertEqual(descriptor_blob[0], blob_array[0]) @@ -553,6 +632,7 @@ def test_findDescByBlobWithLink(self): response, blob_array = db.query(all_queries, [descriptor_blob]) + self.assertEqual(len(blob_array), kn) # This checks that the received blobs is the same as the inserted. self.assertEqual(descriptor_blob[0], blob_array[0])