Skip to content

Commit 2ab65fe

Browse files
Merge pull request apel#323 from Sae126V/add-to-support-logging-for-storage-records
[apel#238] Add storage record type for logger
2 parents ef5571c + ef13637 commit 2ab65fe

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

apel/db/loader/loader.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,14 @@ def load_msg(self, msg_text, signer):
197197
from its text content into the database.
198198
'''
199199
record_types = {
200-
apel.db.records.summary.SummaryRecord: 'Summary',
201-
apel.db.records.job.JobRecord: 'Job',
202-
apel.db.records.normalised_summary.NormalisedSummaryRecord:
203-
'Normalised Summary',
204-
apel.db.records.sync.SyncRecord: 'Sync',
205-
apel.db.records.cloud.CloudRecord: 'Cloud',
206-
apel.db.records.cloud_summary.CloudSummaryRecord:
207-
'Cloud Summary'}
200+
apel.db.records.summary.SummaryRecord: 'Summary',
201+
apel.db.records.job.JobRecord: 'Job',
202+
apel.db.records.normalised_summary.NormalisedSummaryRecord: 'Normalised Summary',
203+
apel.db.records.sync.SyncRecord: 'Sync',
204+
apel.db.records.cloud.CloudRecord: 'Cloud',
205+
apel.db.records.cloud_summary.CloudSummaryRecord: 'Cloud Summary',
206+
apel.db.records.storage.StorageRecord: 'Storage',
207+
}
208208

209209
log.info('Loading message from %s', signer)
210210

test/test_loader.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,11 @@ def test_load_all_single_record(self):
143143
mock_log.assert_has_calls(
144144
[call('Message contains 1 %s record', 'Summary')])
145145

146-
def test_load_all_other_type(self):
147-
"""Check that load_records is called and message is logged correctly when type is other"""
146+
def test_load_all_storage_type(self):
147+
"""Check that load_records calls and logs with storage records.
148+
149+
This checks that load_records is called and the message is logged
150+
correctly when the record type is storage."""
148151
logger = logging.getLogger('loader')
149152
pidfile = os.path.join(self.dir_path, 'pidfile')
150153

@@ -178,7 +181,7 @@ def test_load_all_other_type(self):
178181
self.loader.load_all_msgs()
179182
self.mock_db.load_records.assert_called_once()
180183
mock_log.assert_has_calls(
181-
[call('Message contains %i records', 1)])
184+
[call('Message contains 1 %s record', 'Storage')])
182185

183186
def tearDown(self):
184187
shutil.rmtree(self.dir_path)

0 commit comments

Comments
 (0)