lab random

This commit is contained in:
e-maks
2024-03-17 21:39:29 +03:00
parent 9bca22e57f
commit b73bb79a84
11 changed files with 375 additions and 22 deletions
+43 -4
View File
@@ -2,17 +2,56 @@
import pytest
from hypothesis import given
import json
import hypothesis.strategies as st
from httpx import Client
my_spec = {
"budget_minute_price": 17,
"luxury_minute_price": 37,
"budget_km_price": 11,
"deviation": 0.14,
"inno_discount": 0.06
}
@pytest.fixture(scope="module")
def test_app():
client = Client(base_url=" https://instructors.pg.innopolis.university/innodrive/")
client = Client(base_url="https://instructors.pg.innopolis.university/innodrive/")
yield client # testing happens here
@pytest.mark.parametrize("email", ["i.ivanov@innopolis.university"])
def test_spec(test_app, email):
response = test_app.get("/spec/"+email)
@pytest.mark.parametrize("email", ["m.matantsev@innopolis.university"])
def test_spec(test_app, email):
response = test_app.get("/spec/" + email)
assert response.status_code == 200
@pytest.mark.parametrize("email", ["m.matantsev@innopolis.university"])
@given(numbers=st.integers(min_value=1, max_value=1000))
def test_budget_multiple_requests(test_app, email, numbers):
data = {
"type": "budget",
"plan": "minute",
"distance": 10,
"planned_distance": 10,
"time": numbers,
"planned_time": numbers,
"inno_discount": "no"
}
response = test_app.post("/rangeprice/" + email, content=json.dumps(data))
assert response.json()['price'] == my_spec["budget_minute_price"] * numbers
@pytest.mark.parametrize("email", ["m.matantsev@innopolis.university"])
@given(numbers=st.integers(min_value=1, max_value=1000))
def test_luxury_multiple_requests(test_app, email, numbers):
data = {
"type": "luxury",
"plan": "minute",
"distance": 10,
"planned_distance": 10,
"time": numbers,
"planned_time": numbers,
"inno_discount": "no"
}
response = test_app.post("/rangeprice/" + email, content=json.dumps(data))
assert response.json()['price'] == my_spec["luxury_minute_price"] * numbers