Skip to content

Commit 06e1c53

Browse files
committed
test: test_projects is tested against sync and async interface
1 parent 6d0e2cb commit 06e1c53

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

gitlab/tests/objects/test_async_projects.py renamed to gitlab/tests/objects/test_projects.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,9 @@
66

77

88
class TestProjectSnippets:
9-
@pytest.fixture
10-
def gl(self):
11-
return AsyncGitlab(
12-
"http://localhost",
13-
private_token="private_token",
14-
ssl_verify=True,
15-
api_version=4,
16-
)
17-
189
@respx.mock
1910
@pytest.mark.asyncio
20-
async def test_list_project_snippets(self, gl):
11+
async def test_list_project_snippets(self, gl, gl_get_value):
2112
title = "Example Snippet Title"
2213
visibility = "private"
2314
request = respx.get(
@@ -35,14 +26,16 @@ async def test_list_project_snippets(self, gl):
3526
)
3627

3728
project = gl.projects.get(1, lazy=True)
38-
snippets = await project.snippets.list()
29+
snippets = project.snippets.list()
30+
snippets = await gl_get_value(snippets)
31+
3932
assert len(snippets) == 1
4033
assert snippets[0].title == title
4134
assert snippets[0].visibility == visibility
4235

4336
@respx.mock
4437
@pytest.mark.asyncio
45-
async def test_get_project_snippet(self, gl):
38+
async def test_get_project_snippet(self, gl, gl_get_value):
4639
title = "Example Snippet Title"
4740
visibility = "private"
4841
request = respx.get(
@@ -58,13 +51,14 @@ async def test_get_project_snippet(self, gl):
5851
)
5952

6053
project = gl.projects.get(1, lazy=True)
61-
snippet = await project.snippets.get(1)
54+
snippet = project.snippets.get(1)
55+
snippet = await gl_get_value(snippet)
6256
assert snippet.title == title
6357
assert snippet.visibility == visibility
6458

6559
@respx.mock
6660
@pytest.mark.asyncio
67-
async def test_create_update_project_snippets(self, gl):
61+
async def test_create_update_project_snippets(self, gl, gl_get_value, is_gl_sync):
6862
title = "Example Snippet Title"
6963
new_title = "new-title"
7064
visibility = "private"
@@ -93,18 +87,22 @@ async def test_create_update_project_snippets(self, gl):
9387
)
9488

9589
project = gl.projects.get(1, lazy=True)
96-
snippet = await project.snippets.create(
90+
snippet = project.snippets.create(
9791
{
9892
"title": title,
9993
"file_name": title,
10094
"content": title,
10195
"visibility": visibility,
10296
}
10397
)
98+
snippet = await gl_get_value(snippet)
10499
assert snippet.title == title
105100
assert snippet.visibility == visibility
106101

107102
snippet.title = new_title
108-
await snippet.save()
103+
if is_gl_sync:
104+
snippet.save()
105+
else:
106+
await snippet.save()
109107
assert snippet.title == new_title
110108
assert snippet.visibility == visibility

0 commit comments

Comments
 (0)