From 123bfb753d9ee5e50dc7ed41ba7eeb6a8dbb779e Mon Sep 17 00:00:00 2001 From: Luis Remis Date: Fri, 22 Feb 2019 09:13:26 -0800 Subject: [PATCH] Refactor Python Tests --- tests/python/TestBoundingBox.py | 68 ++++++++++------------ tests/python/TestCommand.py | 87 +++++++++++++++++++++++++++++ tests/python/TestDescriptors.py | 71 +++++++++++++---------- tests/python/TestEntities.py | 51 ++++------------- tests/python/TestEntitiesBlobs.py | 24 ++------ tests/python/TestFindDescriptors.py | 65 +++++++++++---------- tests/python/TestImages.py | 51 +++++++---------- tests/python/TestRetail.py | 25 ++------- tests/python/TestVideos.py | 43 ++++++-------- tests/python/longquery.py | 25 +++++++++ tests/python/run_python_tests.sh | 26 +++++++++ 11 files changed, 305 insertions(+), 231 deletions(-) create mode 100644 tests/python/TestCommand.py diff --git a/tests/python/TestBoundingBox.py b/tests/python/TestBoundingBox.py index f7f2b7ba..6ff049dc 100644 --- a/tests/python/TestBoundingBox.py +++ b/tests/python/TestBoundingBox.py @@ -24,20 +24,10 @@ # THE SOFTWARE. # -from threading import Thread -import sys -import os -import urllib -import time -import json -import unittest -import numpy as np -import vdms - -hostname = "localhost" -port = 55557 - -class TestBoundingBox(unittest.TestCase): +import TestCommand + +class TestBoundingBox(TestCommand.TestCommand): + @classmethod def setUpClass(self): self.number_of_inserts = 2 @@ -113,8 +103,8 @@ def addBoundingBoxwithImage(self, db, numBoxes, imgprops=None): self.assertEqual(response[i+1]["AddBoundingBox"]["status"], 0) def test_addBoundingBox(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() all_queries = [] @@ -144,8 +134,8 @@ def test_addBoundingBox(self): self.assertEqual(response[i]["AddBoundingBox"]["status"], 0) def test_findBoundingBox(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() prefix_name = "find_my_bb_" @@ -180,8 +170,8 @@ def test_findBoundingBox(self): self.assertEqual(response[1]["FindBoundingBox"]["entities"][0]["name"], prefix_name + "1") def test_findBoundingBoxCoordinates(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() prefix_name = "find_my_bb_coords_" @@ -218,8 +208,8 @@ def test_findBoundingBoxCoordinates(self): self.assertEqual(response[i]["FindBoundingBox"]["entities"][0]["_coordinates"]["h"], 100) def test_addBoundingBoxWithImage(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() all_queries = [] imgs_arr = [] @@ -265,8 +255,8 @@ def test_addBoundingBoxWithImage(self): self.assertEqual(response[1]["AddBoundingBox"]["status"], 0) def test_findBoundingBoxesInImage(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() img_name = "my_brain_multiple" imgprops = {} @@ -312,8 +302,8 @@ def test_findBoundingBoxesInImage(self): def test_findBoundingBoxByCoordinates(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() all_queries = [] @@ -340,15 +330,14 @@ def test_findBoundingBoxByCoordinates(self): self.assertEqual(response[0]["FindBoundingBox"]["status"], 0) def test_findBoundingBoxBlob(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() prefix_name = "my_brain_return_" all_queries = [] for i in range(0, self.number_of_inserts): - db = vdms.vdms() - db.connect(hostname, port) + db = self.create_connection() img_name = prefix_name + str(i) imgprops = {} @@ -381,15 +370,14 @@ def test_findBoundingBoxBlob(self): self.assertEqual(response[i]["FindBoundingBox"]["entities"][0]["name"], prefix_name + str(i) + "_bb_0") def test_findBoundingBoxBlobComplex(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() prefix_name = "my_brain_complex_" all_queries = [] for i in range(0, self.number_of_inserts): - db = vdms.vdms() - db.connect(hostname, port) + db = self.create_connection() img_name = prefix_name + str(i) imgprops = {} @@ -425,8 +413,8 @@ def test_findBoundingBoxBlobComplex(self): self.assertIn(test, response[0]["FindBoundingBox"]["entities"]) def test_updateBoundingBox(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() prefix_name = "update_bb_" @@ -473,14 +461,14 @@ def test_updateBoundingBox(self): all_queries.append(query) - response, img_array = db.query(all_queries) + response, img_array = db.query(all_queries) self.assertEqual(response[0]["FindBoundingBox"]["status"], 0) self.assertEqual(response[0]["FindBoundingBox"]["entities"][0]["name"], "updated_bb_0") def test_updateBoundingBoxCoords(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() prefix_name = "update_bb_" @@ -530,7 +518,7 @@ def test_updateBoundingBoxCoords(self): all_queries.append(query) - response, img_array = db.query(all_queries) + response, img_array = db.query(all_queries) self.assertEqual(response[0]["FindBoundingBox"]["status"], 0) self.assertEqual(response[0]["FindBoundingBox"]["entities"][0]["_coordinates"]["x"], 15) diff --git a/tests/python/TestCommand.py b/tests/python/TestCommand.py new file mode 100644 index 00000000..11f62c74 --- /dev/null +++ b/tests/python/TestCommand.py @@ -0,0 +1,87 @@ +# +# The MIT License +# +# @copyright Copyright (c) 2017 Intel Corporation +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, +# merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# + +import sys +import os +import urllib +import time +import json +import unittest +import vdms + +class TestCommand(unittest.TestCase): + + def __init__(self, *args, **kwargs): + super(TestCommand, self).__init__(*args, **kwargs) + + # VDMS Server Info + self.hostname = "localhost" + self.port = 55557 + + def create_connection(self): + + db = vdms.vdms() + db.connect(self.hostname, self.port) + + return db + + def addEntity(self, class_name, properties=None, + constraints=None, + blob = False, # Generic blob + check_status=True): + + addEntity = {} + addEntity["class"] = class_name + + if properties != None: + addEntity["properties"] = properties + if constraints != None: + addEntity["constraints"] = constraints + + query = {} + query["AddEntity"] = addEntity + + all_queries = [] + all_queries.append(query) + + db = self.create_connection() + + if not blob: + response, res_arr = db.query(all_queries) + else: + blob_arr = [] + fd = open("../test_images/brain.png", 'rb') + blob_arr.append(fd.read()) + fd.close() + + addEntity["blob"] = True + + response, res_arr = db.query(all_queries, [blob_arr]) + + if check_status: + self.assertEqual(response[0]["AddEntity"]["status"], 0) + + return response, res_arr diff --git a/tests/python/TestDescriptors.py b/tests/python/TestDescriptors.py index 322ec785..65dc8caa 100644 --- a/tests/python/TestDescriptors.py +++ b/tests/python/TestDescriptors.py @@ -1,22 +1,37 @@ -from threading import Thread -import sys -import os -import urllib -import time -import json -import unittest +# +# The MIT License +# +# @copyright Copyright (c) 2017 Intel Corporation +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, +# merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# + +import TestCommand import numpy as np -import vdms # Yeah, baby -hostname = "localhost" -port = 55557 - -class TestDescriptors(unittest.TestCase): +class TestDescriptors(TestCommand.TestCommand): def addSet(self, name, dim, metric, engine): - db = vdms.vdms() - db.connect(hostname, port) + db = self.create_connection() all_queries = [] @@ -37,8 +52,8 @@ def addSet(self, name, dim, metric, engine): self.assertEqual(response[0]["AddDescriptorSet"]["status"], 0) def test_addSet(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() all_queries = [] @@ -72,8 +87,8 @@ def test_addDifferentSets(self): self.addSet("4075-L2-TileDBDense", 4075, "L2", "TileDBDense") def test_addSetAndDescriptors(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() all_queries = [] @@ -116,8 +131,8 @@ def test_addSetAndDescriptors(self): self.assertEqual(response[0]["AddDescriptor"]["status"], 0) def test_addDescriptorsx1000(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() all_queries = [] @@ -163,8 +178,8 @@ def test_addDescriptorsx1000(self): self.assertEqual(response[x]["AddDescriptor"]["status"], 0) def test_addDescriptorsx1000FaissIVFFlat(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() all_queries = [] @@ -213,8 +228,8 @@ def test_addDescriptorsx1000FaissIVFFlat(self): def test_addDescriptorsx1000TileDBSparse(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() all_queries = [] @@ -262,8 +277,8 @@ def test_addDescriptorsx1000TileDBSparse(self): self.assertEqual(response[x]["AddDescriptor"]["status"], 0) def test_addDescriptorsx1000TileDBDense(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() all_queries = [] @@ -312,8 +327,8 @@ def test_addDescriptorsx1000TileDBDense(self): self.assertEqual(response[x]["AddDescriptor"]["status"], 0) def test_classifyDescriptor(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() all_queries = [] diff --git a/tests/python/TestEntities.py b/tests/python/TestEntities.py index 4e587be3..92885559 100644 --- a/tests/python/TestEntities.py +++ b/tests/python/TestEntities.py @@ -25,24 +25,11 @@ # from threading import Thread -import sys -import os -import urllib -import time -import json -import unittest -import numpy as np -import vdms +import TestCommand -hostname = "localhost" -port = 55557 +class TestEntities(TestCommand.TestCommand): -class TestEntities(unittest.TestCase): - - def addEntity(self, thID, results): - - db = vdms.vdms() - db.connect(hostname, port) + def addSingleEntity(self, thID, results): props = {} props["name"] = "Luis" @@ -50,18 +37,8 @@ def addEntity(self, thID, results): props["age"] = 27 props["threadid"] = thID - addEntity = {} - addEntity["properties"] = props - addEntity["class"] = "AwesomePeople" - - query = {} - query["AddEntity"] = addEntity - - all_queries = [] - all_queries.append(query) - - response, res_arr = db.query(all_queries) - # print (db.get_last_response_str()) + response, arr = self.addEntity("AwesomePeople", properties=props, + check_status=False) try: self.assertEqual(response[0]["AddEntity"]["status"], 0) @@ -72,8 +49,7 @@ def addEntity(self, thID, results): def findEntity(self, thID, results): - db = vdms.vdms() - db.connect(hostname, port) + db = self.create_connection() constraints = {} constraints["threadid"] = ["==",thID] @@ -113,7 +89,7 @@ def test_runMultipleAdds(self): thread_arr = [] results = [None] * concurrency for i in range(0,concurrency): - thread_add = Thread(target=self.addEntity,args=(i, results) ) + thread_add = Thread(target=self.addSingleEntity,args=(i, results) ) thread_add.start() thread_arr.append(thread_add) @@ -133,7 +109,7 @@ def test_runMultipleAdds(self): results = [None] * concurrency * 2 for i in range(0,concurrency): addidx = concurrency + i - thread_add = Thread(target=self.addEntity,args=(addidx, results) ) + thread_add = Thread(target=self.addSingleEntity,args=(addidx, results) ) thread_add.start() thread_arr.append(thread_add) @@ -155,12 +131,11 @@ def test_runMultipleAdds(self): def test_addFindEntity(self): results = [None] * 1 - self.addEntity(0, results); + self.addSingleEntity(0, results); self.findEntity(0, results); def test_addEntityWithLink(self): - db = vdms.vdms() - db.connect(hostname, port) + db = self.create_connection() all_queries = [] @@ -208,8 +183,7 @@ def test_addEntityWithLink(self): def test_FindWithSortKey(self): - db = vdms.vdms() - db.connect(hostname, port) + db = self.create_connection() all_queries = [] @@ -259,8 +233,7 @@ def test_FindWithSortKey(self): def test_FindWithSortBlock(self): - db = vdms.vdms() - db.connect(hostname, port) + db = self.create_connection() all_queries = [] diff --git a/tests/python/TestEntitiesBlobs.py b/tests/python/TestEntitiesBlobs.py index 0da62fde..7116d9eb 100644 --- a/tests/python/TestEntitiesBlobs.py +++ b/tests/python/TestEntitiesBlobs.py @@ -24,25 +24,13 @@ # THE SOFTWARE. # -from threading import Thread -import sys -import os -import urllib -import time -import json -import unittest -import numpy as np -import vdms +import TestCommand -hostname = "localhost" -port = 55557 - -class TestEntitiesBlob(unittest.TestCase): +class TestEntitiesBlob(TestCommand.TestCommand): def test_addEntityWithBlob(self, thID=0): - db = vdms.vdms() - db.connect(hostname, port) + db = self.create_connection() props = {} props["name"] = "Luis" @@ -72,8 +60,7 @@ def test_addEntityWithBlob(self, thID=0): def test_addEntityWithBlobNoBlob(self, thID=0): - db = vdms.vdms() - db.connect(hostname, port) + db = self.create_connection() props = {} props["name"] = "Luis" @@ -100,8 +87,7 @@ def test_addEntityWithBlobNoBlob(self, thID=0): def test_addEntityWithBlobAndFind(self, thID=0): - db = vdms.vdms() - db.connect(hostname, port) + db = self.create_connection() props = {} props["name"] = "Tom" diff --git a/tests/python/TestFindDescriptors.py b/tests/python/TestFindDescriptors.py index 4164a305..3819e668 100644 --- a/tests/python/TestFindDescriptors.py +++ b/tests/python/TestFindDescriptors.py @@ -1,21 +1,37 @@ -from threading import Thread -import sys -import os -import urllib -import time -import json -import unittest +# +# The MIT License +# +# @copyright Copyright (c) 2017 Intel Corporation +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, +# merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# + +import TestCommand import numpy as np -import vdms # Yeah, baby -hostname = "localhost" -port = 55557 - -class TestFindDescriptors(unittest.TestCase): +class TestFindDescriptors(TestCommand.TestCommand): def create_set_and_insert(self, set_name, dims, total): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() all_queries = [] @@ -72,8 +88,7 @@ def test_findDescByConstraints(self): total = 100 self.create_set_and_insert(set_name, dims, total) - db = vdms.vdms() - db.connect(hostname, port) + db = self.create_connection() all_queries = [] @@ -110,8 +125,7 @@ def test_findDescUnusedRef(self): total = 1000 self.create_set_and_insert(set_name, dims, total) - db = vdms.vdms() - db.connect(hostname, port) + db = self.create_connection() all_queries = [] @@ -148,8 +162,7 @@ def test_findDescByConst_get_id(self): total = 100 self.create_set_and_insert(set_name, dims, total) - db = vdms.vdms() - db.connect(hostname, port) + db = self.create_connection() all_queries = [] @@ -186,8 +199,7 @@ def test_findDescByBlob(self): total = 100 self.create_set_and_insert(set_name, dims, total) - db = vdms.vdms() - db.connect(hostname, port) + db = self.create_connection() kn = 3 @@ -238,8 +250,7 @@ def test_findDescByBlobNoResults(self): total = 100 self.create_set_and_insert(set_name, dims, total) - db = vdms.vdms() - db.connect(hostname, port) + db = self.create_connection() kn = 1 @@ -281,8 +292,7 @@ def test_findDescByBlobUnusedRef(self): total = 100 self.create_set_and_insert(set_name, dims, total) - db = vdms.vdms() - db.connect(hostname, port) + db = self.create_connection() kn = 3 @@ -384,8 +394,7 @@ def test_findDescByBlobWithLink(self): dims = 128 total = 100 - db = vdms.vdms() - db.connect(hostname, port) + db = self.create_connection() all_queries = [] diff --git a/tests/python/TestImages.py b/tests/python/TestImages.py index d777f50a..4d715703 100644 --- a/tests/python/TestImages.py +++ b/tests/python/TestImages.py @@ -24,20 +24,9 @@ # THE SOFTWARE. # -from threading import Thread -import sys -import os -import urllib -import time -import json -import unittest -import numpy as np -import vdms +import TestCommand -hostname = "localhost" -port = 55557 - -class TestImages(unittest.TestCase): +class TestImages(TestCommand.TestCommand): #Methos to insert one image def insertImage(self, db, props=None, collections=None, format="png"): @@ -72,8 +61,8 @@ def insertImage(self, db, props=None, collections=None, format="png"): self.assertEqual(response[0]["AddImage"]["status"], 0) def test_addImage(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() all_queries = [] imgs_arr = [] @@ -112,8 +101,8 @@ def test_addImage(self): self.assertEqual(response[i]["AddImage"]["status"], 0) def test_findEntityImage(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() prefix_name = "fent_brain_" @@ -149,8 +138,8 @@ def test_findEntityImage(self): self.assertEqual(response[1]["FindEntity"]["entities"][0]["name"], prefix_name + "1") def test_findImage(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() prefix_name = "fimg_brain_" @@ -181,8 +170,8 @@ def test_findImage(self): self.assertEqual(len(img_array), 2) def test_findImageResults(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() prefix_name = "fimg_results_" @@ -218,8 +207,8 @@ def test_findImageResults(self): self.assertEqual(len(img_array), 2) def test_addImageWithLink(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() all_queries = [] @@ -272,8 +261,8 @@ def test_addImageWithLink(self): self.assertEqual(response[1]["AddImage"]["status"], 0) def test_findImage_multiple_results(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() prefix_name = "fimg_brain_multiple" @@ -305,8 +294,8 @@ def test_findImage_multiple_results(self): self.assertEqual(response[0]["FindImage"]["returned"], number_of_inserts) def test_findImageNoBlob(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() prefix_name = "fimg_no_blob_" @@ -341,8 +330,8 @@ def test_findImageNoBlob(self): self.assertEqual(len(img_array), 0) def test_updateImage(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() prefix_name = "fimg_update_" @@ -374,8 +363,8 @@ def test_updateImage(self): self.assertEqual(len(img_array), 0) def ztest_zFindImageWithCollection(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() prefix_name = "fimg_brain_collection_" number_of_inserts = 4 diff --git a/tests/python/TestRetail.py b/tests/python/TestRetail.py index b4ef9412..55217393 100644 --- a/tests/python/TestRetail.py +++ b/tests/python/TestRetail.py @@ -25,30 +25,19 @@ # from threading import Thread -import sys -import os -import urllib -import time -import json -import unittest -import numpy as np -import vdms - +import TestCommand import longquery - -hostname = "localhost" -port = 55557 +import numpy as np n_cameras = 15 dim = 1000 name = "features_vectors_store1" -class TestEntities(unittest.TestCase): +class TestEntities(TestCommand.TestCommand): def add_descriptor_set(self, name, dim): - db = vdms.vdms() - db.connect(hostname, port) + db = self.create_connection() all_queries = [] @@ -68,8 +57,7 @@ def add_descriptor_set(self, name, dim): def build_store(self): - db = vdms.vdms() - db.connect(hostname, port) + db = self.create_connection() all_queries = [] @@ -230,8 +218,7 @@ def test_concurrent(self): db_list = [] for i in range(0, concurrency): - db = vdms.vdms() - db.connect(hostname, port) + db = self.create_connection() db_list.append(db) results = [None] * concurrency * retries diff --git a/tests/python/TestVideos.py b/tests/python/TestVideos.py index 05b62256..1f7b8546 100644 --- a/tests/python/TestVideos.py +++ b/tests/python/TestVideos.py @@ -24,20 +24,9 @@ # THE SOFTWARE. # -from threading import Thread -import sys -import os -import urllib -import time -import json -import unittest -import numpy as np -import vdms +import TestCommand -hostname = "localhost" -port = 55557 - -class TestVideos(unittest.TestCase): +class TestVideos(TestCommand.TestCommand): #Methos to insert one image def insertVideo(self, db, props=None): @@ -70,8 +59,8 @@ def insertVideo(self, db, props=None): self.assertEqual(response[0]["AddVideo"]["status"], 0) def test_addVideo(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() all_queries = [] video_arr = [] @@ -108,8 +97,8 @@ def test_addVideo(self): self.assertEqual(response[i]["AddVideo"]["status"], 0) def test_findVideo(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() prefix_name = "video_1_" @@ -142,8 +131,8 @@ def test_findVideo(self): self.assertEqual(response[i]["FindVideo"]["status"], 0) def test_findVideoResults(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() prefix_name = "resvideo_1_" @@ -180,8 +169,8 @@ def test_findVideoResults(self): self.assertEqual(response[i]["FindVideo"]["status"], 0) def test_addVideoWithLink(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() all_queries = [] @@ -233,8 +222,8 @@ def test_addVideoWithLink(self): self.assertEqual(response[1]["AddVideo"]["status"], 0) def test_findVid_multiple_results(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() prefix_name = "vid_multiple" @@ -266,8 +255,8 @@ def test_findVid_multiple_results(self): self.assertEqual(response[0]["FindVideo"]["returned"], number_of_inserts) def test_findVideoNoBlob(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() prefix_name = "fvid_no_blob_" @@ -302,8 +291,8 @@ def test_findVideoNoBlob(self): self.assertEqual(len(img_array), 0) def test_updateVideo(self): - db = vdms.vdms() - db.connect(hostname, port) + + db = self.create_connection() prefix_name = "fvid_update_" diff --git a/tests/python/longquery.py b/tests/python/longquery.py index e2305b26..6801fbd9 100644 --- a/tests/python/longquery.py +++ b/tests/python/longquery.py @@ -1,3 +1,28 @@ +# +# The MIT License +# +# @copyright Copyright (c) 2017 Intel Corporation +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, +# merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# import os diff --git a/tests/python/run_python_tests.sh b/tests/python/run_python_tests.sh index bef45ae0..cc878bac 100644 --- a/tests/python/run_python_tests.sh +++ b/tests/python/run_python_tests.sh @@ -1,3 +1,29 @@ +# +# The MIT License +# +# @copyright Copyright (c) 2017 Intel Corporation +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, +# merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# + rm log.log screen.log rm -r test_db