Skip to content

Commit 84e3247

Browse files
committed
test(objects): add unit test for instance audit events
1 parent 35a190c commit 84e3247

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

gitlab/tests/objects/test_audit_events.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pytest
99
import responses
1010

11-
from gitlab.v4.objects.audit_events import ProjectAudit
11+
from gitlab.v4.objects.audit_events import AuditEvent, ProjectAudit
1212

1313
id = 5
1414

@@ -32,11 +32,11 @@
3232
}
3333

3434
audit_events_url = re.compile(
35-
r"http://localhost/api/v4/((groups|projects)/1/)audit_events"
35+
r"http://localhost/api/v4/((groups|projects)/1/)?audit_events"
3636
)
3737

3838
audit_events_url_id = re.compile(
39-
rf"http://localhost/api/v4/((groups|projects)/1/)audit_events/{id}"
39+
rf"http://localhost/api/v4/((groups|projects)/1/)?audit_events/{id}"
4040
)
4141

4242

@@ -54,7 +54,7 @@ def resp_list_audit_events():
5454

5555

5656
@pytest.fixture
57-
def resp_get_variable():
57+
def resp_get_audit_event():
5858
with responses.RequestsMock() as rsps:
5959
rsps.add(
6060
method=responses.GET,
@@ -66,14 +66,27 @@ def resp_get_variable():
6666
yield rsps
6767

6868

69+
def test_list_instance_audit_events(gl, resp_list_audit_events):
70+
audit_events = gl.audit_events.list()
71+
assert isinstance(audit_events, list)
72+
assert isinstance(audit_events[0], AuditEvent)
73+
assert audit_events[0].id == id
74+
75+
76+
def test_get_instance_audit_events(gl, resp_get_audit_event):
77+
audit_event = gl.audit_events.get(id)
78+
assert isinstance(audit_event, AuditEvent)
79+
assert audit_event.id == id
80+
81+
6982
def test_list_project_audit_events(project, resp_list_audit_events):
7083
audit_events = project.audit_events.list()
7184
assert isinstance(audit_events, list)
7285
assert isinstance(audit_events[0], ProjectAudit)
7386
assert audit_events[0].id == id
7487

7588

76-
def test_get_project_audit_events(project, resp_get_variable):
89+
def test_get_project_audit_events(project, resp_get_audit_event):
7790
audit_event = project.audit_events.get(id)
7891
assert isinstance(audit_event, ProjectAudit)
7992
assert audit_event.id == id

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy