-
Notifications
You must be signed in to change notification settings - Fork 602
/
Copy pathtest_docker_compose.py
58 lines (48 loc) · 1.65 KB
/
test_docker_compose.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import requests
import gdown
import zipfile
def get_file():
url = 'https://drive.google.com/uc?id=1omhIvzbXM9t0mU3hDFqLDpbKpwqyW__b'
gdown.download(url)
with zipfile.ZipFile('example_img.zip', 'r') as zip_ref:
zip_ref.extractall('./data')
def test_load():
get_file()
response = requests.post(
"http://127.0.0.1:5000/img/load",
json={"File": "/data/example_img"}
)
assert response.status_code == 200
assert response.json() == "Successfully loaded data!"
def test_progress():
response = requests.get("http://127.0.0.1:5000/progress")
assert response.status_code == 200
assert response.json() == "current: 20, total: 20"
def test_count():
response = requests.post("http://127.0.0.1:5000/img/count")
assert response.status_code == 200
assert response.json() == 20
def test_get_img():
response = requests.get(
'http://127.0.0.1:5000/data?image_path=%2Fdata%2Fexample_img%2Ftest.jpg'
)
assert response.status_code == 200
def test_upload_img():
_test_upload_file = './data/example_img/test.jpg'
_files = {'image': open(_test_upload_file, 'rb')}
response = requests.post(
'http://127.0.0.1:5000/img/upload',
files = _files
)
assert response.status_code == 200
def test_search():
_test_upload_file = './data/example_img/test.jpg'
_files = {'image': open(_test_upload_file, 'rb')}
response = requests.post(
'http://127.0.0.1:5000/img/search',
files = _files
)
assert response.status_code == 200
def test_drop():
response = requests.post("http://127.0.0.1:5000/img/drop")
assert response.status_code == 200