summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNejc Habjan <hab.nejc@gmail.com>2021-03-07 12:44:59 +0100
committerNejc Habjan <hab.nejc@gmail.com>2021-03-07 12:44:59 +0100
commit84e3247d0cd3ddb1f3aa0ac91fb977c3e1e197b5 (patch)
treecd33eefb2cdf044b992f05482f443688c96e8264
parent35a190cfa0902d6a298aba0a3135c5a99edfe0fa (diff)
downloadgitlab-84e3247d0cd3ddb1f3aa0ac91fb977c3e1e197b5.tar.gz
test(objects): add unit test for instance audit events
-rw-r--r--gitlab/tests/objects/test_audit_events.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/gitlab/tests/objects/test_audit_events.py b/gitlab/tests/objects/test_audit_events.py
index 75bc11c..8da77ae 100644
--- a/gitlab/tests/objects/test_audit_events.py
+++ b/gitlab/tests/objects/test_audit_events.py
@@ -8,7 +8,7 @@ import re
import pytest
import responses
-from gitlab.v4.objects.audit_events import ProjectAudit
+from gitlab.v4.objects.audit_events import AuditEvent, ProjectAudit
id = 5
@@ -32,11 +32,11 @@ audit_events_content = {
}
audit_events_url = re.compile(
- r"http://localhost/api/v4/((groups|projects)/1/)audit_events"
+ r"http://localhost/api/v4/((groups|projects)/1/)?audit_events"
)
audit_events_url_id = re.compile(
- rf"http://localhost/api/v4/((groups|projects)/1/)audit_events/{id}"
+ rf"http://localhost/api/v4/((groups|projects)/1/)?audit_events/{id}"
)
@@ -54,7 +54,7 @@ def resp_list_audit_events():
@pytest.fixture
-def resp_get_variable():
+def resp_get_audit_event():
with responses.RequestsMock() as rsps:
rsps.add(
method=responses.GET,
@@ -66,6 +66,19 @@ def resp_get_variable():
yield rsps
+def test_list_instance_audit_events(gl, resp_list_audit_events):
+ audit_events = gl.audit_events.list()
+ assert isinstance(audit_events, list)
+ assert isinstance(audit_events[0], AuditEvent)
+ assert audit_events[0].id == id
+
+
+def test_get_instance_audit_events(gl, resp_get_audit_event):
+ audit_event = gl.audit_events.get(id)
+ assert isinstance(audit_event, AuditEvent)
+ assert audit_event.id == id
+
+
def test_list_project_audit_events(project, resp_list_audit_events):
audit_events = project.audit_events.list()
assert isinstance(audit_events, list)
@@ -73,7 +86,7 @@ def test_list_project_audit_events(project, resp_list_audit_events):
assert audit_events[0].id == id
-def test_get_project_audit_events(project, resp_get_variable):
+def test_get_project_audit_events(project, resp_get_audit_event):
audit_event = project.audit_events.get(id)
assert isinstance(audit_event, ProjectAudit)
assert audit_event.id == id