test(data/model/log): add more log_action tests
temp
This commit is contained in:
parent
ea740d15ba
commit
d0aaaaa1ef
3 changed files with 71 additions and 51 deletions
|
@ -112,16 +112,20 @@ def log_action(kind_name, user_or_organization_name, performer=None, repository=
|
|||
|
||||
kind = _get_log_entry_kind(kind_name)
|
||||
metadata_json = json.dumps(metadata, default=_json_serialize)
|
||||
log_data = {
|
||||
'kind': kind,
|
||||
'account': account,
|
||||
'performer': performer,
|
||||
'repository': repository,
|
||||
'ip': ip,
|
||||
'metadata_json': metadata_json,
|
||||
'datetime': timestamp
|
||||
}
|
||||
try:
|
||||
LogEntry.create(kind=kind, account=account, performer=performer,
|
||||
repository=repository, ip=ip, metadata_json=metadata_json,
|
||||
datetime=timestamp)
|
||||
LogEntry.create(**log_data)
|
||||
except PeeweeException as ex:
|
||||
if kind_name is 'pull_repo' and config.app_config.get('ALLOW_PULLS_WITHOUT_STRICT_LOGGING'):
|
||||
logger.exception('log_action failed',
|
||||
extra={'exception': ex, 'action_kind': kind, 'account': account,
|
||||
'performer': performer, 'repository': repository, 'ip': ip,
|
||||
'metadata_json': metadata_json, 'datetime': timestamp})
|
||||
logger.exception('log_action failed', extra=({'exception': ex}).update(log_data))
|
||||
else:
|
||||
raise
|
||||
|
||||
|
|
Reference in a new issue