Skip to content

Commit

Permalink
update test for new email subject
Browse files Browse the repository at this point in the history
  • Loading branch information
rv0lt committed Oct 9, 2024
1 parent 05e94ef commit 5e6f8f7
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1655,7 +1655,10 @@ def create_file_versions(project: models.Project):

# Error email should be sent
assert len(outbox1) == 1
assert "[INVOICING CRONJOB] <ERROR> Error in monthly-usage cronjob" in outbox1[-1].subject
assert (
"[INVOICING CRONJOB] (DEVELOPMENT) <ERROR> Error in monthly-usage cronjob"
in outbox1[-1].subject
)
assert "What to do:" in outbox1[-1].body

# No usage rows should have been saved
Expand Down Expand Up @@ -1688,7 +1691,10 @@ def create_file_versions(project: models.Project):

# Error email should have been sent
assert len(outbox2) == 1
assert "[INVOICING CRONJOB] <ERROR> Error in monthly-usage cronjob" in outbox2[-1].subject
assert (
"[INVOICING CRONJOB] (DEVELOPMENT) <ERROR> Error in monthly-usage cronjob"
in outbox2[-1].subject
)
assert "What to do:" in outbox2[-1].body

# Project versions should not be altered
Expand Down Expand Up @@ -1721,7 +1727,10 @@ def create_file_versions(project: models.Project):

# Email should be sent
assert len(outbox3) == 1
assert "[INVOICING CRONJOB] Usage records available for collection" in outbox3[-1].subject
assert (
"[INVOICING CRONJOB] (DEVELOPMENT) Usage records available for collection"
in outbox3[-1].subject
)
assert (
"The calculation of the monthly usage succeeded; The byte hours for all active projects have been saved to the database."
in outbox3[-1].body
Expand Down Expand Up @@ -1918,7 +1927,7 @@ def run_command_and_check_output(months_to_test, start_time):
# Verify output and sent email
assert len(outbox) == 1
assert (
"[SEND-USAGE CRONJOB] Usage records attached in the present mail"
"[SEND-USAGE CRONJOB] (DEVELOPMENT) Usage records attached in the present mail"
in outbox[-1].subject
)
assert f"Here is the usage for the last {months_to_test} months." in outbox[-1].body
Expand Down Expand Up @@ -2055,5 +2064,8 @@ def test_send_usage_error_csv(client, cli_runner, capfd: LogCaptureFixture):

# Verify error email :- At least one email was sent
assert len(outbox) == 1
assert "[SEND-USAGE CRONJOB] <ERROR> Error in send-usage cronjob" in outbox[-1].subject
assert (
"[SEND-USAGE CRONJOB] (DEVELOPMENT) <ERROR> Error in send-usage cronjob"
in outbox[-1].subject
)
assert "There was an error in the cronjob 'send-usage'" in outbox[-1].body

0 comments on commit 5e6f8f7

Please sign in to comment.