forked from FOSS-Community/LinkLiberate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_main.py
More file actions
35 lines (25 loc) · 1.05 KB
/
test_main.py
File metadata and controls
35 lines (25 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from unittest.mock import Mock
from fastapi.testclient import TestClient
from src.link_liberate.main import app
def test_index_page():
client = TestClient(app)
response = client.get("/")
assert response.status_code == 200
assert "request" in response.context
def test_web():
client = TestClient(app)
response = client.get("/liberate")
assert response.status_code == 200
assert "request" in response.context
def test_web_post(mocker):
# Patch the get_db function to return the db mock
mocker.patch("src.link_liberate.database.Session_Local", return_value=Mock())
client_mock = TestClient(app)
response = client_mock.post("/liberate", data={"content": "valid_content"})
assert response.status_code == 200
def test_get_link(mocker):
# Patch the get_db function to return the db mock
mocker.patch("src.link_liberate.database.Session_Local", return_value=Mock())
client_mock = TestClient(app)
response = client_mock.get("/valid_uuid", follow_redirects=False)
assert response.status_code == 301