Skip to content

Commit 223b78b

Browse files
committed
add tests
1 parent c71089d commit 223b78b

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

tests/container_test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
import sys
3+
root_dir = os.path.join(os.path.realpath(os.path.pardir), 'piper')
4+
sys.path.insert(1, root_dir)
5+
6+
from piper.utils import docker_utils as du
7+
from piper.envs import CurrentEnv
8+
9+
def test_start_container():
10+
with CurrentEnv() as env:
11+
print(env)
12+
assert True == True
13+
14+
# du.get_container('asba', 'dkfja')
15+
16+
17+
import os
18+
19+
def test_dummy():
20+
print(f'file {os.path.dirname(__file__)}')
21+
print(f'name', os.path.dirname(__name__))
22+
assert True == True

tests/running_piper_test.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# pytest -vs tests/running_piper_test.py::TestDocker
2+
import requests
3+
4+
main_app_url = f'http://localhost:8788'
5+
6+
class TestDocker():
7+
'''
8+
класс тестирования API приложения запущщеного в докер контейнере
9+
health_check
10+
run
11+
'''
12+
def test_health_check(self):
13+
url = f'{main_app_url}/health_check'
14+
print(url)
15+
result = requests.post(url)
16+
assert result.status_code == 200
17+
18+
def test_run(self):
19+
url = f'{main_app_url}/run'
20+
print(url)
21+
data = {'value': 'hello, world'}
22+
response = requests.post(url, json=data)
23+
result = dict(response.json())
24+
need_result = f"{data.get('value')}TEST"
25+
print(f'need_result is {need_result}')
26+
print(f"docker result is {result.get('value')}")
27+
28+
assert response.status_code == 200
29+
assert need_result == result.get('value')
30+
31+
32+
class TestVenv():
33+
'''
34+
класс тестирования приложения в среде venv
35+
dummy
36+
'''
37+
def test_dummy(self):
38+
assert 1 / 0

0 commit comments

Comments
 (0)