Skip to content

Commit a8ef796

Browse files
committed
test: rework application tests in async way
1 parent f694b20 commit a8ef796

File tree

2 files changed

+96
-120
lines changed

2 files changed

+96
-120
lines changed

gitlab/tests/objects/test_application.py

Lines changed: 0 additions & 120 deletions
This file was deleted.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import re
2+
3+
import pytest
4+
import respx
5+
from httpx.status_codes import StatusCode
6+
7+
from gitlab import Gitlab
8+
9+
10+
class TestApplicationAppearance:
11+
@pytest.fixture
12+
def gl(self):
13+
return Gitlab(
14+
"http://localhost",
15+
private_token="private_token",
16+
ssl_verify=True,
17+
api_version="4",
18+
)
19+
20+
@respx.mock
21+
@pytest.mark.asyncio
22+
async def test_get_update_appearance(self, gl):
23+
title = "GitLab Test Instance"
24+
new_title = "new-title"
25+
description = "gitlab-test.example.com"
26+
new_description = "new-description"
27+
28+
request_get_appearance = respx.get(
29+
"http://localhost/api/v4/application/appearance",
30+
content={
31+
"title": title,
32+
"description": description,
33+
"logo": "/uploads/-/system/appearance/logo/1/logo.png",
34+
"header_logo": "/uploads/-/system/appearance/header_logo/1/header.png",
35+
"favicon": "/uploads/-/system/appearance/favicon/1/favicon.png",
36+
"new_project_guidelines": "Please read the FAQs for help.",
37+
"header_message": "",
38+
"footer_message": "",
39+
"message_background_color": "#e75e40",
40+
"message_font_color": "#ffffff",
41+
"email_header_and_footer_enabled": False,
42+
},
43+
status_code=StatusCode.OK,
44+
)
45+
request_update_appearance = respx.put(
46+
"http://localhost/api/v4/application/appearance",
47+
content={
48+
"title": new_title,
49+
"description": new_description,
50+
"logo": "/uploads/-/system/appearance/logo/1/logo.png",
51+
"header_logo": "/uploads/-/system/appearance/header_logo/1/header.png",
52+
"favicon": "/uploads/-/system/appearance/favicon/1/favicon.png",
53+
"new_project_guidelines": "Please read the FAQs for help.",
54+
"header_message": "",
55+
"footer_message": "",
56+
"message_background_color": "#e75e40",
57+
"message_font_color": "#ffffff",
58+
"email_header_and_footer_enabled": False,
59+
},
60+
status_code=StatusCode.OK,
61+
)
62+
63+
appearance = await gl.appearance.get()
64+
assert appearance.title == title
65+
assert appearance.description == description
66+
appearance.title = new_title
67+
appearance.description = new_description
68+
await appearance.save()
69+
assert appearance.title == new_title
70+
assert appearance.description == new_description
71+
72+
@respx.mock
73+
@pytest.mark.asyncio
74+
async def test_update_appearance(self, gl):
75+
new_title = "new-title"
76+
new_description = "new-description"
77+
78+
request = respx.put(
79+
re.compile("^http://localhost/api/v4/application/appearance"),
80+
content={
81+
"title": new_title,
82+
"description": new_description,
83+
"logo": "/uploads/-/system/appearance/logo/1/logo.png",
84+
"header_logo": "/uploads/-/system/appearance/header_logo/1/header.png",
85+
"favicon": "/uploads/-/system/appearance/favicon/1/favicon.png",
86+
"new_project_guidelines": "Please read the FAQs for help.",
87+
"header_message": "",
88+
"footer_message": "",
89+
"message_background_color": "#e75e40",
90+
"message_font_color": "#ffffff",
91+
"email_header_and_footer_enabled": False,
92+
},
93+
status_code=StatusCode.OK,
94+
)
95+
96+
await gl.appearance.update(title=new_title, description=new_description)

0 commit comments

Comments
 (0)