Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
rv0lt committed Oct 3, 2024
1 parent 09ab317 commit 3134a77
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_motd_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,30 @@ def test_add_new_motd_ok(caplog: LogCaptureFixture):
logging.INFO,
"Response from API about adding a MOTD.",
) in caplog.record_tuples


# send_motd


def test_send_motd_all(caplog: LogCaptureFixture):
"""Send a MOTD to all users."""

motd_id = 1
response_message = "Response from API about sending a MOTD."
returned_response: Dict = {"message": response_message}

with caplog.at_level(logging.INFO):
# Create mocker
with Mocker() as mock:
# Create mocked request - real request not executed
mock.post(DDSEndpoint.MOTD_SEND, status_code=200, json=returned_response)

with motd_manager.MotdManager(authenticate=False, no_prompt=True) as mtdm:
mtdm.token = {} # required, otherwise none
mtdm.send_motd(motd_id=motd_id, unit_personnel_only=False) # Send motd

assert (
"dds_cli.motd_manager",
logging.INFO,
response_message,
) in caplog.record_tuples

0 comments on commit 3134a77

Please sign in to comment.