lab-random-maksktl created by GitHub Classroom
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

57 lines
1.8 KiB

# This is the template for the InnoDrive e2e and domain and computation test cases.
import pytest
from hypothesis import given
import ujson
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/")
yield client # testing happens here
@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=ujson.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=ujson.dumps(data))
assert response.json()['price'] == my_spec["luxury_minute_price"] * numbers