6
6
7
7
8
8
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
-
18
9
@respx .mock
19
10
@pytest .mark .asyncio
20
- async def test_list_project_snippets (self , gl ):
11
+ async def test_list_project_snippets (self , gl , gl_get_value ):
21
12
title = "Example Snippet Title"
22
13
visibility = "private"
23
14
request = respx .get (
@@ -35,14 +26,16 @@ async def test_list_project_snippets(self, gl):
35
26
)
36
27
37
28
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
+
39
32
assert len (snippets ) == 1
40
33
assert snippets [0 ].title == title
41
34
assert snippets [0 ].visibility == visibility
42
35
43
36
@respx .mock
44
37
@pytest .mark .asyncio
45
- async def test_get_project_snippet (self , gl ):
38
+ async def test_get_project_snippet (self , gl , gl_get_value ):
46
39
title = "Example Snippet Title"
47
40
visibility = "private"
48
41
request = respx .get (
@@ -58,13 +51,14 @@ async def test_get_project_snippet(self, gl):
58
51
)
59
52
60
53
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 )
62
56
assert snippet .title == title
63
57
assert snippet .visibility == visibility
64
58
65
59
@respx .mock
66
60
@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 ):
68
62
title = "Example Snippet Title"
69
63
new_title = "new-title"
70
64
visibility = "private"
@@ -93,18 +87,22 @@ async def test_create_update_project_snippets(self, gl):
93
87
)
94
88
95
89
project = gl .projects .get (1 , lazy = True )
96
- snippet = await project .snippets .create (
90
+ snippet = project .snippets .create (
97
91
{
98
92
"title" : title ,
99
93
"file_name" : title ,
100
94
"content" : title ,
101
95
"visibility" : visibility ,
102
96
}
103
97
)
98
+ snippet = await gl_get_value (snippet )
104
99
assert snippet .title == title
105
100
assert snippet .visibility == visibility
106
101
107
102
snippet .title = new_title
108
- await snippet .save ()
103
+ if is_gl_sync :
104
+ snippet .save ()
105
+ else :
106
+ await snippet .save ()
109
107
assert snippet .title == new_title
110
108
assert snippet .visibility == visibility
0 commit comments