|
2 | 2 | GitLab API: https://docs.gitlab.com/ce/api/projects.html |
3 | 3 | """ |
4 | 4 |
|
5 | | -from unittest.mock import mock_open, patch |
6 | | - |
7 | 5 | import pytest |
8 | 6 | import responses |
9 | 7 |
|
10 | | -from gitlab import exceptions |
11 | 8 | from gitlab.const import DEVELOPER_ACCESS, SEARCH_SCOPE_ISSUES |
12 | 9 | from gitlab.v4.objects import ( |
13 | 10 | Project, |
|
52 | 49 | "name": "name", |
53 | 50 | }, |
54 | 51 | } |
55 | | -upload_file_content = { |
56 | | - "alt": "filename", |
57 | | - "url": "/uploads/66dbcd21ec5d24ed6ea225176098d52b/filename.png", |
58 | | - "full_path": "/namespace/project/uploads/66dbcd21ec5d24ed6ea225176098d52b/filename.png", |
59 | | - "markdown": "", |
60 | | -} |
| 52 | + |
61 | 53 | share_project_content = { |
62 | 54 | "id": 1, |
63 | 55 | "project_id": 1, |
@@ -334,19 +326,6 @@ def resp_delete_project(accepted_content): |
334 | 326 | yield rsps |
335 | 327 |
|
336 | 328 |
|
337 | | -@pytest.fixture |
338 | | -def resp_upload_file_project(): |
339 | | - with responses.RequestsMock() as rsps: |
340 | | - rsps.add( |
341 | | - method=responses.POST, |
342 | | - url="http://localhost/api/v4/projects/1/uploads", |
343 | | - json=upload_file_content, |
344 | | - content_type="application/json", |
345 | | - status=201, |
346 | | - ) |
347 | | - yield rsps |
348 | | - |
349 | | - |
350 | 329 | @pytest.fixture |
351 | 330 | def resp_share_project(): |
352 | 331 | with responses.RequestsMock() as rsps: |
@@ -682,29 +661,6 @@ def test_delete_project(project, resp_delete_project): |
682 | 661 | project.delete() |
683 | 662 |
|
684 | 663 |
|
685 | | -def test_upload_file(project, resp_upload_file_project): |
686 | | - project.upload("filename.png", "raw\nfile\ndata") |
687 | | - |
688 | | - |
689 | | -def test_upload_file_with_filepath(project, resp_upload_file_project): |
690 | | - with patch("builtins.open", mock_open(read_data="raw\nfile\ndata")): |
691 | | - project.upload("filename.png", None, "/filepath") |
692 | | - |
693 | | - |
694 | | -def test_upload_file_without_filepath_nor_filedata(project): |
695 | | - with pytest.raises( |
696 | | - exceptions.GitlabUploadError, match="No file contents or path specified" |
697 | | - ): |
698 | | - project.upload("filename.png") |
699 | | - |
700 | | - |
701 | | -def test_upload_file_with_filepath_and_filedata(project): |
702 | | - with pytest.raises( |
703 | | - exceptions.GitlabUploadError, match="File contents and file path specified" |
704 | | - ): |
705 | | - project.upload("filename.png", "filedata", "/filepath") |
706 | | - |
707 | | - |
708 | 664 | def test_share_project(project, group, resp_share_project): |
709 | 665 | project.share(group.id, DEVELOPER_ACCESS) |
710 | 666 |
|
|
0 commit comments