summaryrefslogtreecommitdiff
path: root/tests/unit/objects/test_snippets.py
diff options
context:
space:
mode:
authorNejc Habjan <hab.nejc@gmail.com>2021-12-01 01:04:53 +0100
committerGitHub <noreply@github.com>2021-12-01 01:04:53 +0100
commit8d76826fa64460e504acc5924f859f8dbc246b42 (patch)
tree083fefada982c795e2415092794db429abb0c184 /tests/unit/objects/test_snippets.py
parent5a1678f43184bd459132102cc13cf8426fe0449d (diff)
parent86ab04e54ea4175f10053decfad5086cda7aa024 (diff)
downloadgitlab-master.tar.gz
Merge pull request #1723 from python-gitlab/jlvillal/dead_mastermaster
Close-out `master` branch
Diffstat (limited to 'tests/unit/objects/test_snippets.py')
-rw-r--r--tests/unit/objects/test_snippets.py89
1 files changed, 0 insertions, 89 deletions
diff --git a/tests/unit/objects/test_snippets.py b/tests/unit/objects/test_snippets.py
deleted file mode 100644
index 2540fc3..0000000
--- a/tests/unit/objects/test_snippets.py
+++ /dev/null
@@ -1,89 +0,0 @@
-"""
-GitLab API: https://docs.gitlab.com/ce/api/project_snippets.html
- https://docs.gitlab.com/ee/api/snippets.html (todo)
-"""
-
-import pytest
-import responses
-
-title = "Example Snippet Title"
-visibility = "private"
-new_title = "new-title"
-
-
-@pytest.fixture
-def resp_snippet():
- content = {
- "title": title,
- "description": "More verbose snippet description",
- "file_name": "example.txt",
- "content": "source code with multiple lines",
- "visibility": visibility,
- }
-
- with responses.RequestsMock(assert_all_requests_are_fired=False) as rsps:
- rsps.add(
- method=responses.GET,
- url="http://localhost/api/v4/projects/1/snippets",
- json=[content],
- content_type="application/json",
- status=200,
- )
- rsps.add(
- method=responses.GET,
- url="http://localhost/api/v4/projects/1/snippets/1",
- json=content,
- content_type="application/json",
- status=200,
- )
- rsps.add(
- method=responses.POST,
- url="http://localhost/api/v4/projects/1/snippets",
- json=content,
- content_type="application/json",
- status=200,
- )
-
- updated_content = dict(content)
- updated_content["title"] = new_title
- updated_content["visibility"] = visibility
-
- rsps.add(
- method=responses.PUT,
- url="http://localhost/api/v4/projects/1/snippets",
- json=updated_content,
- content_type="application/json",
- status=200,
- )
- yield rsps
-
-
-def test_list_project_snippets(project, resp_snippet):
- snippets = project.snippets.list()
- assert len(snippets) == 1
- assert snippets[0].title == title
- assert snippets[0].visibility == visibility
-
-
-def test_get_project_snippet(project, resp_snippet):
- snippet = project.snippets.get(1)
- assert snippet.title == title
- assert snippet.visibility == visibility
-
-
-def test_create_update_project_snippets(project, resp_snippet):
- snippet = project.snippets.create(
- {
- "title": title,
- "file_name": title,
- "content": title,
- "visibility": visibility,
- }
- )
- assert snippet.title == title
- assert snippet.visibility == visibility
-
- snippet.title = new_title
- snippet.save()
- assert snippet.title == new_title
- assert snippet.visibility == visibility