1
+ import os
1
2
from datetime import date
2
3
3
- import os
4
4
import git
5
5
import pytest
6
6
from git import GitCommandError , Repo , TagObject
@@ -136,10 +136,11 @@ def test_push_new_version_with_custom_branch(mock_git):
136
136
@mock .patch .dict (
137
137
os .environ ,
138
138
{
139
- k : v for k , v in os .environ .items ()
140
- if k not in ['GITHUB_REPOSITORY' , 'CI_PROJECT_NAMESPACE' , 'CI_PROJECT_NAME' ]
139
+ k : v
140
+ for k , v in os .environ .items ()
141
+ if k not in ["GITHUB_REPOSITORY" , "CI_PROJECT_NAMESPACE" , "CI_PROJECT_NAME" ]
141
142
},
142
- clear = True
143
+ clear = True ,
143
144
)
144
145
@pytest .mark .parametrize (
145
146
"origin_url,expected_result" ,
@@ -210,17 +211,26 @@ class FakeRemote:
210
211
os .environ ,
211
212
{
212
213
** os .environ ,
213
- ' GITHUB_REPOSITORY' : ' group/subgroup/project' ,
214
+ " GITHUB_REPOSITORY" : " group/subgroup/project" ,
214
215
},
215
- clear = True
216
+ clear = True ,
216
217
)
217
218
@pytest .mark .parametrize (
218
219
"origin_url,expected_result" ,
219
220
[
220
221
("https://github.com/group/project.git" , ("group/subgroup" , "project" )),
221
- ("https://github.com/group/subgroup/project.git" , ("group/subgroup" , "project" )),
222
- ("https://github.com/group/sub.group/project.git" , ("group/subgroup" , "project" )),
223
- ("https://github.com/group/subgroup/pro.ject.git" , ("group/subgroup" , "project" )),
222
+ (
223
+ "https://github.com/group/subgroup/project.git" ,
224
+ ("group/subgroup" , "project" ),
225
+ ),
226
+ (
227
+ "https://github.com/group/sub.group/project.git" ,
228
+ ("group/subgroup" , "project" ),
229
+ ),
230
+ (
231
+ "https://github.com/group/subgroup/pro.ject.git" ,
232
+ ("group/subgroup" , "project" ),
233
+ ),
224
234
],
225
235
)
226
236
def test_get_repository_owner_and_name_github (mocker , origin_url , expected_result ):
@@ -239,18 +249,27 @@ class FakeRemote:
239
249
os .environ ,
240
250
{
241
251
** os .environ ,
242
- ' CI_PROJECT_NAMESPACE' : ' group/subgroup' ,
243
- ' CI_PROJECT_NAME' : ' project' ,
252
+ " CI_PROJECT_NAMESPACE" : " group/subgroup" ,
253
+ " CI_PROJECT_NAME" : " project" ,
244
254
},
245
- clear = True
255
+ clear = True ,
246
256
)
247
257
@pytest .mark .parametrize (
248
258
"origin_url,expected_result" ,
249
259
[
250
- ("https://gitlab.example.com/group/subgroup/project.git" , ("group/subgroup" , "project" )),
251
- ("https://gitlab.example.com/group/subgroup/project" , ("group/subgroup" , "project" )),
252
- ("https://gitlab.example.com/group/project" , ("group/subgroup" , "project" )),
253
- ("https://gitlab-ci-token:MySuperToken@gitlab.example.com/group/subgroup/project.git" , ("group/subgroup" , "project" )),
260
+ (
261
+ "https://gitlab.example.com/group/subgroup/project.git" ,
262
+ ("group/subgroup" , "project" ),
263
+ ),
264
+ (
265
+ "https://gitlab.example.com/group/subgroup/project" ,
266
+ ("group/subgroup" , "project" ),
267
+ ),
268
+ ("https://gitlab.example.com/group/project" , ("group/subgroup" , "project" )),
269
+ (
270
+ "https://gitlab-ci-token:MySuperToken@gitlab.example.com/group/subgroup/project.git" ,
271
+ ("group/subgroup" , "project" ),
272
+ ),
254
273
],
255
274
)
256
275
def test_get_repository_owner_and_name_gitlab (mocker , origin_url , expected_result ):
0 commit comments