Convert creation_time to string
The message to be serialized to JSON has a creation_time field that is of datetime type. The json.dumps method is unable to serialize this. Changing creation_time to timestamp based on review comments and to keep it consistent with monasca-api. Change-Id: Ibbff895e545788cb64b8733adcd6d060f11ef6c0
This commit is contained in:
parent
b61b6afa82
commit
8f297f1222
|
@ -313,9 +313,11 @@ class LogCreatorNewEnvelope(unittest.TestCase):
|
|||
tenant_id = 'a_tenant'
|
||||
none = None
|
||||
meta = {'tenantId': tenant_id, 'region': none}
|
||||
timestamp = (datetime.datetime.utcnow() -
|
||||
datetime.datetime(1970, 1, 1)).total_seconds()
|
||||
expected_envelope = {
|
||||
'log': expected_log,
|
||||
'creation_time': datetime.datetime.utcnow(),
|
||||
'creation_time': timestamp,
|
||||
'meta': meta
|
||||
}
|
||||
|
||||
|
|
|
@ -199,9 +199,11 @@ class LogCreator(object):
|
|||
return log_object
|
||||
|
||||
def new_log_envelope(self, log_object, tenant_id):
|
||||
timestamp = (datetime.datetime.utcnow() -
|
||||
datetime.datetime(1970, 1, 1)).total_seconds()
|
||||
return {
|
||||
'log': log_object,
|
||||
'creation_time': datetime.datetime.utcnow(),
|
||||
'creation_time': timestamp,
|
||||
'meta': self._create_meta_info(tenant_id)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue