mirror of
https://github.com/QualityInUse/lab-random-maksktl.git
synced 2026-08-05 12:05:27 +03:00
lab random
This commit is contained in:
+43
-4
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user