Skip to content

Commit 8559fb0

Browse files
authored
chore(tests): port app logs test from deis/deis#5005 (#1064)
used has_calls instead of assert_called_with since there are other logs knocking around from AppSettings and others that are not relevant in this test Closes #597
1 parent 02718a3 commit 8559fb0

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

rootfs/api/tests/test_app.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,19 @@ def test_app_logs(self, mock_requests, mock_get):
132132
@mock.patch('api.models.logger')
133133
def test_app_release_notes_in_logs(self, mock_requests, mock_logger):
134134
"""Verifies that an app's release summary is dumped into the logs."""
135-
self.create_app()
135+
app_id = self.create_app()
136+
app = App.objects.get(id=app_id)
136137

137138
# check app logs
138-
exp_msg = "autotest created initial release"
139-
exp_log_call = mock.call(logging.INFO, exp_msg)
140-
mock_logger.log.has_calls(exp_log_call)
139+
exp_msg = "[{app_id}]: {self.user.username} created initial release".format(**locals())
140+
mock_logger.log.has_calls(logging.INFO, exp_msg)
141+
app.log('hello world')
142+
exp_msg = "[{app_id}]: hello world".format(**locals())
143+
mock_logger.log.has_calls(logging.INFO, exp_msg)
144+
app.log('goodbye world', logging.WARNING)
145+
# assert logging with a different log level
146+
exp_msg = "[{app_id}]: goodbye world".format(**locals())
147+
mock_logger.log.has_calls(logging.WARNING, exp_msg)
141148

142149
def test_app_errors(self, mock_requests):
143150
response = self.client.post('/v2/apps', {'id': 'camelCase'})

0 commit comments

Comments
 (0)