Skip to content

Commit

Permalink
Merge pull request apel#323 from Sae126V/add-to-support-logging-for-s…
Browse files Browse the repository at this point in the history
…torage-records

[apel#238] Add storage record type for logger
  • Loading branch information
tofu-rocketry authored Sep 18, 2024
2 parents ef5571c + ef13637 commit 2ab65fe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
16 changes: 8 additions & 8 deletions apel/db/loader/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ def load_msg(self, msg_text, signer):
from its text content into the database.
'''
record_types = {
apel.db.records.summary.SummaryRecord: 'Summary',
apel.db.records.job.JobRecord: 'Job',
apel.db.records.normalised_summary.NormalisedSummaryRecord:
'Normalised Summary',
apel.db.records.sync.SyncRecord: 'Sync',
apel.db.records.cloud.CloudRecord: 'Cloud',
apel.db.records.cloud_summary.CloudSummaryRecord:
'Cloud Summary'}
apel.db.records.summary.SummaryRecord: 'Summary',
apel.db.records.job.JobRecord: 'Job',
apel.db.records.normalised_summary.NormalisedSummaryRecord: 'Normalised Summary',
apel.db.records.sync.SyncRecord: 'Sync',
apel.db.records.cloud.CloudRecord: 'Cloud',
apel.db.records.cloud_summary.CloudSummaryRecord: 'Cloud Summary',
apel.db.records.storage.StorageRecord: 'Storage',
}

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

Expand Down
9 changes: 6 additions & 3 deletions test/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,11 @@ def test_load_all_single_record(self):
mock_log.assert_has_calls(
[call('Message contains 1 %s record', 'Summary')])

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

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

def tearDown(self):
shutil.rmtree(self.dir_path)
Expand Down

0 comments on commit 2ab65fe

Please sign in to comment.