diff --git a/pytest/__pycache__/test_booking.cpython-313-pytest-8.3.5.pyc b/pytest/__pycache__/test_booking.cpython-313-pytest-8.3.5.pyc new file mode 100644 index 0000000..dd4fcd1 Binary files /dev/null and b/pytest/__pycache__/test_booking.cpython-313-pytest-8.3.5.pyc differ diff --git a/pytest/__pycache__/test_test.cpython-313-pytest-8.3.5.pyc b/pytest/__pycache__/test_test.cpython-313-pytest-8.3.5.pyc index fb9f113..83d6ac0 100644 Binary files a/pytest/__pycache__/test_test.cpython-313-pytest-8.3.5.pyc and b/pytest/__pycache__/test_test.cpython-313-pytest-8.3.5.pyc differ diff --git a/pytest/test_booking.py b/pytest/test_booking.py new file mode 100644 index 0000000..132ddbe --- /dev/null +++ b/pytest/test_booking.py @@ -0,0 +1,25 @@ +import requests +import pytest + + +def test_health_check(): + assert requests.get("https://restful-booker.herokuapp.com/ping").status_code == 201 + + +@pytest.fixture +def auth_token(): + body = {"username": "admin", "password": "password123"} + + resp = requests.post("https://restful-booker.herokuapp.com/auth", params=body) + + resp.raise_for_status() + + print(resp.text) + + token = resp.json()["token"] + + return token + +@pytest.mark.xfail(reason="Default credentials don't work on the prod server") +def test_get_auth_token(auth_token): + assert auth_token \ No newline at end of file diff --git a/pytest/test_test.py b/pytest/test_test.py index e45003a..0fb21b6 100644 --- a/pytest/test_test.py +++ b/pytest/test_test.py @@ -1,8 +1,9 @@ -import pytest +import pytest -# Thanks to https://pydevtools.com/handbook/tutorial/setting-up-testing-with-pytest-and-uv/ +# Thanks to https://pydevtools.com/handbook/tutorial/setting-up-testing-with-pytest-and-uv/ # for the guide + def add(a, b): return a + b @@ -47,4 +48,4 @@ def test_divide(): def test_divide_by_zero(): with pytest.raises(ValueError): - divide(5, 0) \ No newline at end of file + divide(5, 0)