Skip to content

Commit

Permalink
Fix mocked response test
Browse files Browse the repository at this point in the history
  • Loading branch information
da1910 committed Feb 3, 2025
1 parent 6887b7b commit 4e01614
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tests/test_mocked_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import json
import uuid

from requests_mock import ANY

Expand Down Expand Up @@ -50,19 +51,27 @@ def test_get_all_audit_log_entries(api_url, mock_client, mocker):
with mocker:
response_id = "766b96c2-9b91-4625-a271-46b1da89eb55"
response = {"searchResultIdentifier": f"{response_id}"}
empty_response_id = str(uuid.uuid4())
empty_response = {"searchResultIdentifier": f"{empty_response_id}"}
mocker.post(
f"{api_url}/proxy/v1.svc/mi/api/v1/lists/audit/search", status_code=201, json=response
f"{api_url}/proxy/v1.svc/mi/api/v1/lists/audit/search",
[{"status_code": 201, "json": response}, {"status_code": 201, "json": empty_response}],
)
mocker.get(
f"{api_url}/proxy/v1.svc/mi/api/v1/lists/audit/search/results/{response_id}",
status_code=200,
json=json.loads(examples_as_strings["test_get_all_audit_log_entries"]),
)
mocker.get(
f"{api_url}/proxy/v1.svc/mi/api/v1/lists/audit/search/results/{empty_response_id}",
status_code=200,
json=[],
)

log_entries = list(mock_client.get_all_audit_log_entries())

assert len(log_entries) == 2
assert log_entries[0].list_identifier == "f235a25c-4deb-45cf-b6fd-c4fbaca3cbd0"
assert log_entries[0].action == AuditLogAction.LISTCREATED
assert log_entries[1].list_identifier == "f235a25c-4deb-45cf-b6fd-c4fbaca3cbd0"
assert log_entries[1].action == AuditLogAction.LISTSETTOAWAITINGAPPROVAL
assert log_entries[1].action == AuditLogAction.LISTCREATED
assert log_entries[0].list_identifier == "f235a25c-4deb-45cf-b6fd-c4fbaca3cbd0"
assert log_entries[0].action == AuditLogAction.LISTSETTOAWAITINGAPPROVAL

0 comments on commit 4e01614

Please sign in to comment.