| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,9 +5,30 @@ | |||
| 5 | 5 | import pytest | |
| 6 | 6 | import responses | |
| 7 | 7 | ||
| 8 | - from gitlab.v4.objects import Project | ||
| 8 | + from gitlab.v4.objects import ( | ||
| 9 | + Project, | ||
| 10 | + ProjectFork, | ||
| 11 | + ProjectUser, | ||
| 12 | + StarredProject, | ||
| 13 | + UserProject, | ||
| 14 | + ) | ||
| 9 | 15 | ||
| 10 | 16 | project_content = {"name": "name", "id": 1} | |
| 17 | + languages_content = { | ||
| 18 | + "python": 80.00, | ||
| 19 | + "ruby": 99.99, | ||
| 20 | + "CoffeeScript": 0.01, | ||
| 21 | + } | ||
| 22 | + user_content = { | ||
| 23 | + "name": "first", | ||
| 24 | + "id": 1, | ||
| 25 | + "state": "active", | ||
| 26 | + } | ||
| 27 | + forks_content = [ | ||
| 28 | + { | ||
| 29 | + "id": 1, | ||
| 30 | + }, | ||
| 31 | + ] | ||
| 11 | 32 | import_content = { | |
| 12 | 33 | "id": 1, | |
| 13 | 34 | "name": "project", | |
@@ -28,6 +49,71 @@ def resp_get_project(): | |||
| 28 | 49 | yield rsps | |
| 29 | 50 | ||
| 30 | 51 | ||
| 52 | + @pytest.fixture | ||
| 53 | + def resp_user_projects(): | ||
| 54 | + with responses.RequestsMock() as rsps: | ||
| 55 | + rsps.add( | ||
| 56 | + method=responses.GET, | ||
| 57 | + url="http://localhost/api/v4/users/1/projects", | ||
| 58 | + json=[project_content], | ||
| 59 | + content_type="application/json", | ||
| 60 | + status=200, | ||
| 61 | + ) | ||
| 62 | + yield rsps | ||
| 63 | + | ||
| 64 | + | ||
| 65 | + @pytest.fixture | ||
| 66 | + def resp_starred_projects(): | ||
| 67 | + with responses.RequestsMock() as rsps: | ||
| 68 | + rsps.add( | ||
| 69 | + method=responses.GET, | ||
| 70 | + url="http://localhost/api/v4/users/1/starred_projects", | ||
| 71 | + json=[project_content], | ||
| 72 | + content_type="application/json", | ||
| 73 | + status=200, | ||
| 74 | + ) | ||
| 75 | + yield rsps | ||
| 76 | + | ||
| 77 | + | ||
| 78 | + @pytest.fixture | ||
| 79 | + def resp_list_users(): | ||
| 80 | + with responses.RequestsMock() as rsps: | ||
| 81 | + rsps.add( | ||
| 82 | + method=responses.GET, | ||
| 83 | + url="http://localhost/api/v4/projects/1/users", | ||
| 84 | + json=[user_content], | ||
| 85 | + content_type="application/json", | ||
| 86 | + status=200, | ||
| 87 | + ) | ||
| 88 | + yield rsps | ||
| 89 | + | ||
| 90 | + | ||
| 91 | + @pytest.fixture | ||
| 92 | + def resp_list_forks(): | ||
| 93 | + with responses.RequestsMock() as rsps: | ||
| 94 | + rsps.add( | ||
| 95 | + method=responses.GET, | ||
| 96 | + url="http://localhost/api/v4/projects/1/forks", | ||
| 97 | + json=forks_content, | ||
| 98 | + content_type="application/json", | ||
| 99 | + status=200, | ||
| 100 | + ) | ||
| 101 | + yield rsps | ||
| 102 | + | ||
| 103 | + | ||
| 104 | + @pytest.fixture | ||
| 105 | + def resp_list_languages(): | ||
| 106 | + with responses.RequestsMock() as rsps: | ||
| 107 | + rsps.add( | ||
| 108 | + method=responses.GET, | ||
| 109 | + url="http://localhost/api/v4/projects/1/languages", | ||
| 110 | + json=languages_content, | ||
| 111 | + content_type="application/json", | ||
| 112 | + status=200, | ||
| 113 | + ) | ||
| 114 | + yield rsps | ||
| 115 | + | ||
| 116 | + | ||
| 31 | 117 | @pytest.fixture | |
| 32 | 118 | def resp_list_projects(): | |
| 33 | 119 | with responses.RequestsMock() as rsps: | |
@@ -98,19 +184,26 @@ def test_import_bitbucket_server(gl, resp_import_bitbucket_server): | |||
| 98 | 184 | assert res["import_status"] == "scheduled" | |
| 99 | 185 | ||
| 100 | 186 | ||
| 101 | - @pytest.mark.skip(reason="missing test") | ||
| 102 | - def test_list_user_projects(gl): | ||
| 103 | - pass | ||
| 187 | + def test_list_user_projects(user, resp_user_projects): | ||
| 188 | + user_project = user.projects.list()[0] | ||
| 189 | + assert isinstance(user_project, UserProject) | ||
| 190 | + assert user_project.name == "name" | ||
| 191 | + assert user_project.id == 1 | ||
| 104 | 192 | ||
| 105 | 193 | ||
| 106 | - @pytest.mark.skip(reason="missing test") | ||
| 107 | - def test_list_user_starred_projects(gl): | ||
| 108 | - pass | ||
| 194 | + def test_list_user_starred_projects(user, resp_starred_projects): | ||
| 195 | + starred_projects = user.starred_projects.list()[0] | ||
| 196 | + assert isinstance(starred_projects, StarredProject) | ||
| 197 | + assert starred_projects.name == "name" | ||
| 198 | + assert starred_projects.id == 1 | ||
| 109 | 199 | ||
| 110 | 200 | ||
| 111 | - @pytest.mark.skip(reason="missing test") | ||
| 112 | - def test_list_project_users(gl): | ||
| 113 | - pass | ||
| 201 | + def test_list_project_users(project, resp_list_users): | ||
| 202 | + user = project.users.list()[0] | ||
| 203 | + assert isinstance(user, ProjectUser) | ||
| 204 | + assert user.id == 1 | ||
| 205 | + assert user.name == "first" | ||
| 206 | + assert user.state == "active" | ||
| 114 | 207 | ||
| 115 | 208 | ||
| 116 | 209 | @pytest.mark.skip(reason="missing test") | |
@@ -133,9 +226,10 @@ def test_fork_project(gl): | |||
| 133 | 226 | pass | |
| 134 | 227 | ||
| 135 | 228 | ||
| 136 | - @pytest.mark.skip(reason="missing test") | ||
| 137 | - def test_list_project_forks(gl): | ||
| 138 | - pass | ||
| 229 | + def test_list_project_forks(project, resp_list_forks): | ||
| 230 | + fork = project.forks.list()[0] | ||
| 231 | + assert isinstance(fork, ProjectFork) | ||
| 232 | + assert fork.id == 1 | ||
| 139 | 233 | ||
| 140 | 234 | ||
| 141 | 235 | @pytest.mark.skip(reason="missing test") | |
@@ -153,9 +247,13 @@ def test_list_project_starrers(gl): | |||
| 153 | 247 | pass | |
| 154 | 248 | ||
| 155 | 249 | ||
| 156 | - @pytest.mark.skip(reason="missing test") | ||
| 157 | - def test_get_project_languages(gl): | ||
| 158 | - pass | ||
| 250 | + def test_get_project_languages(project, resp_list_languages): | ||
| 251 | + python = project.languages().get("python") | ||
| 252 | + ruby = project.languages().get("ruby") | ||
| 253 | + coffee_script = project.languages().get("CoffeeScript") | ||
| 254 | + assert python == 80.00 | ||
| 255 | + assert ruby == 99.99 | ||
| 256 | + assert coffee_script == 00.01 | ||
| 159 | 257 | ||
| 160 | 258 | ||
| 161 | 259 | @pytest.mark.skip(reason="missing test") | |
@@ -233,13 +331,11 @@ def test_delete_project_push_rule(gl): | |||
| 233 | 331 | pass | |
| 234 | 332 | ||
| 235 | 333 | ||
| 236 | - def test_transfer_project(gl, resp_transfer_project): | ||
| 237 | - project = gl.projects.get(1, lazy=True) | ||
| 334 | + def test_transfer_project(project, resp_transfer_project): | ||
| 238 | 335 | project.transfer("test-namespace") | |
| 239 | 336 | ||
| 240 | 337 | ||
| 241 | - def test_transfer_project_deprecated_warns(gl, resp_transfer_project): | ||
| 242 | - project = gl.projects.get(1, lazy=True) | ||
| 338 | + def test_transfer_project_deprecated_warns(project, resp_transfer_project): | ||
| 243 | 339 | with pytest.warns(DeprecationWarning): | |
| 244 | 340 | project.transfer_project("test-namespace") | |
| 245 | 341 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments