Browse Source

Merge "Fix date format to be compliant with UTC"

changes/64/666164/1
Zuul 2 years ago
committed by Gerrit Code Review
parent
commit
1df4688d10
3 changed files with 8 additions and 4 deletions
  1. +0
    -1
      qinling/db/sqlalchemy/model_base.py
  2. +7
    -2
      qinling/tests/unit/api/controllers/v1/test_job.py
  3. +1
    -1
      qinling/utils/common.py

+ 0
- 1
qinling/db/sqlalchemy/model_base.py View File

@ -85,7 +85,6 @@ class _QinlingModelBase(oslo_models.ModelBase, oslo_models.TimestampMixin):
updated_at = getattr(self, 'updated_at')
if updated_at:
setattr(m, 'updated_at', updated_at.isoformat(' '))
return m
def __repr__(self):


+ 7
- 2
qinling/tests/unit/api/controllers/v1/test_job.py View File

@ -217,9 +217,12 @@ class TestJobController(base.APITest):
count=10
).id
next_hour_and_half = datetime.utcnow() + timedelta(hours=1.5)
next_two_hours = datetime.utcnow() + timedelta(hours=2)
req_body = {
'next_execution_time': str(
datetime.utcnow() + timedelta(hours=1.5)
next_hour_and_half.strftime('%Y-%m-%dT%H:%M:%SZ')
),
'pattern': '1 */1 * * *'
}
@ -239,7 +242,9 @@ class TestJobController(base.APITest):
req_body = {
'status': status.RUNNING,
'next_execution_time': str(datetime.utcnow() + timedelta(hours=2)),
'next_execution_time': str(
next_two_hours.strftime('%Y-%m-%dT%H:%M:%SZ')
),
}
resp = self.app.put_json('/v1/jobs/%s' % job_id, req_body)


+ 1
- 1
qinling/utils/common.py View File

@ -85,7 +85,7 @@ def datetime_to_str(dct, attr_name):
"""Convert datetime object in dict to string."""
if (dct.get(attr_name) is not None and
not isinstance(dct.get(attr_name), six.string_types)):
dct[attr_name] = dct[attr_name].isoformat(' ')
dct[attr_name] = dct[attr_name].strftime('%Y-%m-%dT%H:%M:%SZ')
def generate_unicode_uuid(dashed=True):


Loading…
Cancel
Save