Passed
Push — master ( fd4969...54df52 )
by
unknown
01:50
created

TestDropCollection.test_drop_collection_not_existed()   A

Complexity

Conditions 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nop 2
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
import pdb
2
import pytest
3
import logging
4
import itertools
5
from time import sleep
6
from multiprocessing import Process
7
from milvus import IndexType, MetricType
8
from utils import *
9
10
uniq_id = "drop_collection"
11
default_fields = gen_default_fields() 
12
13
14
class TestDropCollection:
15
16
    """
17
    ******************************************************************
18
      The following cases are used to test `drop_collection` function
19
    ******************************************************************
20
    """
21
    def test_drop_collection(self, connect, collection):
22
        '''
23
        target: test delete collection created with correct params 
24
        method: create collection and then delete, 
25
            assert the value returned by delete method
26
        expected: status ok, and no collection in collections
27
        '''
28
        connect.drop_collection(collection)
29
        time.sleep(2)
30
        assert not connect.has_collection(collection)
31
32
    @pytest.mark.level(2)
33
    def test_drop_collection_without_connection(self, collection, dis_connect):
34
        '''
35
        target: test describe collection, without connection
36
        method: drop collection with correct params, with a disconnected instance
37
        expected: drop raise exception
38
        '''
39
        with pytest.raises(Exception) as e:
40
            dis_connect.drop_collection(collection)
41
42
    def test_drop_collection_not_existed(self, connect):
43
        '''
44
        target: test if collection not created
45
        method: random a collection name, which not existed in db, 
46
            assert the exception raised returned by drp_collection method
47
        expected: False
48
        '''
49
        collection_name = gen_unique_str(uniq_id)
50
        with pytest.raises(Exception) as e:
51
            connect.drop_collection(collection_name)
52
53
54 View Code Duplication
class TestDropCollectionInvalid(object):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
55
    """
56
    Test has collection with invalid params
57
    """
58
    @pytest.fixture(
59
        scope="function",
60
        params=gen_invalid_strs()
61
    )
62
    def get_collection_name(self, request):
63
        yield request.param
64
65
    @pytest.mark.level(2)
66
    def test_drop_collection_with_invalid_collectionname(self, connect, get_collection_name):
67
        collection_name = get_collection_name
68
        with pytest.raises(Exception) as e:
69
            connect.has_collection(collection_name)
70
71
    @pytest.mark.level(2)
72
    def test_drop_collection_with_empty_collectionname(self, connect):
73
        collection_name = ''
74
        with pytest.raises(Exception) as e:
75
            connect.has_collection(collection_name)
76
77
    @pytest.mark.level(2)
78
    def test_drop_collection_with_none_collectionname(self, connect):
79
        collection_name = None
80
        with pytest.raises(Exception) as e:
81
            connect.has_collection(collection_name)
82