Repository navigation
Expand file tree
/
Copy pathtest_commits.py
More file actions
57 lines (41 loc) · 1.82 KB
/
Copy pathtest_commits.py
File metadata and controls
57 lines (41 loc) · 1.82 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""Tests for the commits API endpoints."""
async def test_list_commits_empty(client):
response = await client.get("/api/commits")
assert response.status_code == 200
assert response.json() == []
async def test_list_commits(client, sample_commit):
response = await client.get("/api/commits")
assert response.status_code == 200
data = response.json()
assert len(data) == 1
assert data[0]["sha"] == sample_commit.sha
assert data[0]["author"] == "Test Author"
assert data[0]["python_version"]["major"] == 3
assert data[0]["python_version"]["minor"] == 14
async def test_list_commits_pagination(client, sample_commit):
response = await client.get("/api/commits", params={"skip": 0, "limit": 1})
assert response.status_code == 200
assert len(response.json()) == 1
response = await client.get("/api/commits", params={"skip": 1, "limit": 1})
assert response.status_code == 200
assert len(response.json()) == 0
async def test_get_commit_by_sha(client, sample_commit):
response = await client.get(f"/api/commits/{sample_commit.sha}")
assert response.status_code == 200
data = response.json()
assert data["sha"] == sample_commit.sha
assert data["message"] == "Test commit"
async def test_get_commit_not_found(client):
response = await client.get("/api/commits/" + "f" * 40)
assert response.status_code == 404
async def test_python_versions_empty(client):
response = await client.get("/api/python-versions")
assert response.status_code == 200
assert response.json() == []
async def test_python_versions(client, sample_benchmark_result):
response = await client.get("/api/python-versions")
assert response.status_code == 200
data = response.json()
assert len(data) == 1
assert data[0]["major"] == 3
assert data[0]["minor"] == 14