Skip to content

Commit 17bdb94

Browse files
committed
Update test cases #72
Former-commit-id: 235f189d364d1f94afb12548105059201d273c52
1 parent 94386c9 commit 17bdb94

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

tests/milvus_python_test/test_add_vectors.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ def test_add_vector_has_table(self, connect, table):
5050
'''
5151
vector = gen_single_vector(dim)
5252
status, ids = connect.add_vectors(table, vector)
53-
ret = connect.has_table(table)
54-
assert ret == True
53+
assert assert_has_table(connect, table)
5554

5655
@pytest.mark.timeout(ADD_TIMEOUT)
5756
def test_delete_table_add_vector(self, connect, table):
@@ -618,8 +617,7 @@ def test_add_vector_has_table(self, connect, ip_table):
618617
'''
619618
vector = gen_single_vector(dim)
620619
status, ids = connect.add_vectors(ip_table, vector)
621-
ret = connect.has_table(ip_table)
622-
assert ret == True
620+
assert assert_has_table(connect, ip_table)
623621

624622
@pytest.mark.timeout(ADD_TIMEOUT)
625623
def test_delete_table_add_vector(self, connect, ip_table):

tests/milvus_python_test/test_table.py

+11-12
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def test_delete_table(self, connect, table):
264264
expected: status ok, and no table in tables
265265
'''
266266
status = connect.delete_table(table)
267-
assert not connect.has_table(table)
267+
assert not assert_has_table(connect, table)
268268

269269
def test_delete_table_ip(self, connect, ip_table):
270270
'''
@@ -274,7 +274,7 @@ def test_delete_table_ip(self, connect, ip_table):
274274
expected: status ok, and no table in tables
275275
'''
276276
status = connect.delete_table(ip_table)
277-
assert not connect.has_table(ip_table)
277+
assert not assert_has_table(connect, ip_table)
278278

279279
@pytest.mark.level(2)
280280
def test_table_delete_without_connection(self, table, dis_connect):
@@ -314,7 +314,7 @@ def test_delete_table_repeatedly(self, connect):
314314
connect.create_table(param)
315315
status = connect.delete_table(table_name)
316316
time.sleep(1)
317-
assert not connect.has_table(table_name)
317+
assert not assert_has_table(connect, table_name)
318318

319319
def test_delete_create_table_repeatedly(self, connect):
320320
'''
@@ -371,7 +371,7 @@ def _test_delete_table_multiprocessing(self, args):
371371
def deletetable(milvus):
372372
status = milvus.delete_table(table)
373373
# assert not status.code==0
374-
assert milvus.has_table(table)
374+
assert assert_has_table(milvus, table)
375375
assert status.OK()
376376

377377
for i in range(process_num):
@@ -411,11 +411,10 @@ def _test_delete_table_multiprocessing_multitable(self, connect):
411411
def delete(connect,ids):
412412
i = 0
413413
while i < loop_num:
414-
# assert connect.has_table(table[ids*8+i])
415414
status = connect.delete_table(table[ids*process_num+i])
416415
time.sleep(2)
417416
assert status.OK()
418-
assert not connect.has_table(table[ids*process_num+i])
417+
assert not assert_has_table(connect, table[ids*process_num+i])
419418
i = i + 1
420419

421420
for i in range(process_num):
@@ -444,7 +443,7 @@ def test_has_table(self, connect):
444443
'index_file_size': index_file_size,
445444
'metric_type': MetricType.L2}
446445
connect.create_table(param)
447-
assert connect.has_table(table_name)
446+
assert assert_has_table(connect, table_name)
448447

449448
def test_has_table_ip(self, connect):
450449
'''
@@ -458,7 +457,7 @@ def test_has_table_ip(self, connect):
458457
'index_file_size': index_file_size,
459458
'metric_type': MetricType.IP}
460459
connect.create_table(param)
461-
assert connect.has_table(table_name)
460+
assert assert_has_table(connect, table_name)
462461

463462
@pytest.mark.level(2)
464463
def test_has_table_without_connection(self, table, dis_connect):
@@ -468,7 +467,7 @@ def test_has_table_without_connection(self, table, dis_connect):
468467
expected: has table raise exception
469468
'''
470469
with pytest.raises(Exception) as e:
471-
status = dis_connect.has_table(table)
470+
assert_has_table(dis_connect, table)
472471

473472
def test_has_table_not_existed(self, connect):
474473
'''
@@ -478,7 +477,7 @@ def test_has_table_not_existed(self, connect):
478477
expected: False
479478
'''
480479
table_name = gen_unique_str("test_table")
481-
assert not connect.has_table(table_name)
480+
assert not assert_has_table(connect, table_name)
482481

483482
"""
484483
******************************************************************
@@ -700,7 +699,7 @@ def test_create_table_with_invalid_dimension(self, connect, get_dim):
700699
'dimension': dimension,
701700
'index_file_size': index_file_size,
702701
'metric_type': MetricType.L2}
703-
if isinstance(dimension, int) and dimension > 0:
702+
if isinstance(dimension, int):
704703
status = connect.create_table(param)
705704
assert not status.OK()
706705
else:
@@ -778,7 +777,7 @@ def preload_table(connect, **params):
778777
return status
779778

780779
def has(connect, **params):
781-
status = connect.has_table(params["table_name"])
780+
status = assert_has_table(connect, params["table_name"])
782781
return status
783782

784783
def show(connect, **params):

tests/milvus_python_test/utils.py

+5
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,11 @@ def gen_params(index_types, nlists):
462462
return gen_params(index_types, nlists)
463463

464464

465+
def assert_has_table(conn, table_name):
466+
status, ok = conn.has_table(table_name)
467+
return status.OK() and ok
468+
469+
465470
if __name__ == "__main__":
466471
import numpy
467472

0 commit comments

Comments
 (0)