summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNejc Habjan <nejc.habjan@siemens.com>2023-03-12 10:58:32 +0100
committerJohn Villalovos <john@sodarock.com>2023-03-12 20:51:01 -0700
commit1bc56d164a7692cf3aaeedfa1ed2fb869796df03 (patch)
treed2c625ab3855f2aa58f3803ab7d1a05a4f64fcc6
parent847004be021b4a514e41bf28afb9d87e8643ddba (diff)
downloadgitlab-1bc56d164a7692cf3aaeedfa1ed2fb869796df03.tar.gz
test(unit): consistently use inline fixtures
-rw-r--r--tests/unit/conftest.py5
-rw-r--r--tests/unit/fixtures/todo.json75
-rw-r--r--tests/unit/objects/test_todos.py39
3 files changed, 31 insertions, 88 deletions
diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py
index 476e41c..4358c2d 100644
--- a/tests/unit/conftest.py
+++ b/tests/unit/conftest.py
@@ -3,11 +3,6 @@ import pytest
import gitlab
-@pytest.fixture(scope="session")
-def fixture_dir(test_dir):
- return test_dir / "unit" / "fixtures"
-
-
@pytest.fixture
def gl():
return gitlab.Gitlab(
diff --git a/tests/unit/fixtures/todo.json b/tests/unit/fixtures/todo.json
deleted file mode 100644
index 93b2151..0000000
--- a/tests/unit/fixtures/todo.json
+++ /dev/null
@@ -1,75 +0,0 @@
-[
- {
- "id": 102,
- "project": {
- "id": 2,
- "name": "Gitlab Ce",
- "name_with_namespace": "Gitlab Org / Gitlab Ce",
- "path": "gitlab-ce",
- "path_with_namespace": "gitlab-org/gitlab-ce"
- },
- "author": {
- "name": "Administrator",
- "username": "root",
- "id": 1,
- "state": "active",
- "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
- "web_url": "https://gitlab.example.com/root"
- },
- "action_name": "marked",
- "target_type": "MergeRequest",
- "target": {
- "id": 34,
- "iid": 7,
- "project_id": 2,
- "title": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.",
- "description": "Et ea et omnis illum cupiditate. Dolor aspernatur tenetur ducimus facilis est nihil. Quo esse cupiditate molestiae illo corrupti qui quidem dolor.",
- "state": "opened",
- "created_at": "2016-06-17T07:49:24.419Z",
- "updated_at": "2016-06-17T07:52:43.484Z",
- "target_branch": "tutorials_git_tricks",
- "source_branch": "DNSBL_docs",
- "upvotes": 0,
- "downvotes": 0,
- "author": {
- "name": "Maxie Medhurst",
- "username": "craig_rutherford",
- "id": 12,
- "state": "active",
- "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon",
- "web_url": "https://gitlab.example.com/craig_rutherford"
- },
- "assignee": {
- "name": "Administrator",
- "username": "root",
- "id": 1,
- "state": "active",
- "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
- "web_url": "https://gitlab.example.com/root"
- },
- "source_project_id": 2,
- "target_project_id": 2,
- "labels": [],
- "work_in_progress": false,
- "milestone": {
- "id": 32,
- "iid": 2,
- "project_id": 2,
- "title": "v1.0",
- "description": "Assumenda placeat ea voluptatem voluptate qui.",
- "state": "active",
- "created_at": "2016-06-17T07:47:34.163Z",
- "updated_at": "2016-06-17T07:47:34.163Z",
- "due_date": null
- },
- "merge_when_pipeline_succeeds": false,
- "merge_status": "cannot_be_merged",
- "subscribed": true,
- "user_notes_count": 7
- },
- "target_url": "https://gitlab.example.com/gitlab-org/gitlab-ce/merge_requests/7",
- "body": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.",
- "state": "pending",
- "created_at": "2016-06-17T07:52:35.225Z"
- }
-]
diff --git a/tests/unit/objects/test_todos.py b/tests/unit/objects/test_todos.py
index cee8d01..c934a33 100644
--- a/tests/unit/objects/test_todos.py
+++ b/tests/unit/objects/test_todos.py
@@ -1,20 +1,43 @@
"""
GitLab API: https://docs.gitlab.com/ce/api/todos.html
"""
-
-import json
-
import pytest
import responses
from gitlab.v4.objects import Todo
-@pytest.fixture()
-def json_content(fixture_dir):
- with open(fixture_dir / "todo.json", "r", encoding="utf-8") as f:
- todo_content = f.read()
- return json.loads(todo_content)
+@pytest.fixture
+def json_content():
+ return [
+ {
+ "id": 102,
+ "project": {
+ "id": 2,
+ "name": "Gitlab Ce",
+ "name_with_namespace": "Gitlab Org / Gitlab Ce",
+ "path": "gitlab-ce",
+ "path_with_namespace": "gitlab-org/gitlab-ce",
+ },
+ "author": {
+ "name": "Administrator",
+ "username": "root",
+ "id": 1,
+ },
+ "action_name": "marked",
+ "target_type": "MergeRequest",
+ "target": {
+ "id": 34,
+ "iid": 7,
+ "project_id": 2,
+ "assignee": {
+ "name": "Administrator",
+ "username": "root",
+ "id": 1,
+ },
+ },
+ }
+ ]
@pytest.fixture