Skip to content

Commit

Permalink
Add more testing for FindDesc
Browse files Browse the repository at this point in the history
  • Loading branch information
luisremis committed Apr 3, 2019
1 parent d734a82 commit 51ce4b1
Showing 1 changed file with 81 additions and 1 deletion.
82 changes: 81 additions & 1 deletion tests/python/TestFindDescriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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])
Expand Down

0 comments on commit 51ce4b1

Please sign in to comment.