-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PP-2018] Replace email attachments with links to S3 on time tracking… (
- Loading branch information
1 parent
ff63d23
commit 44008e2
Showing
4 changed files
with
39 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
from palace.manager.sqlalchemy.model.time_tracking import PlaytimeEntry, PlaytimeSummary | ||
from palace.manager.util.datetime_helpers import datetime_utc, previous_months, utc_now | ||
from tests.fixtures.database import DatabaseTransactionFixture | ||
from tests.fixtures.services import ServicesEmailFixture | ||
from tests.fixtures.services import ServicesEmailFixture, ServicesFixture | ||
|
||
|
||
def create_playtime_entries( | ||
|
@@ -533,6 +533,7 @@ def test_do_run( | |
self, | ||
db: DatabaseTransactionFixture, | ||
services_email_fixture: ServicesEmailFixture, | ||
services_fixture: ServicesFixture, | ||
): | ||
identifier = db.identifier() | ||
collection = db.default_collection() | ||
|
@@ -663,6 +664,11 @@ def test_do_run( | |
) | ||
|
||
reporting_name = "test cm" | ||
|
||
mock_s3_service = MagicMock() | ||
mock_s3_service.generate_url.return_value = "http://test" | ||
services_fixture.services.storage.public.override(mock_s3_service) | ||
|
||
with ( | ||
patch("palace.manager.scripts.playtime_entries.csv.writer") as writer, | ||
patch( | ||
|
@@ -799,15 +805,15 @@ def test_do_run( | |
# verify the number of unique loans | ||
assert len(loan_identifiers) == sum([x.args[0][7] for x in call_args[1:]]) | ||
assert services_email_fixture.mock_emailer.send.call_count == 1 | ||
mock_s3_service.store_stream.assert_called_once() | ||
mock_s3_service.generate_url.assert_called_once() | ||
assert services_email_fixture.mock_emailer.send.call_args == call( | ||
subject=f"{reporting_name}: Playtime Summaries {cutoff} - {until}", | ||
sender=services_email_fixture.sender_email, | ||
receivers=["[email protected]"], | ||
text="", | ||
text="Download Report here -> http://test \n\nThis report will be available for download for 30 days.", | ||
html=None, | ||
attachments={ | ||
f"playtime-summary-{reporting_name.replace(' ', '_')}-{cutoff}-{until}.csv": "" | ||
}, # Mock objects do not write data | ||
attachments=None, | ||
) | ||
|
||
def test_no_reporting_email(self, db: DatabaseTransactionFixture): | ||
|