Fix time checking and tests

This commit is contained in:
Ian Fillion-de Kiewit 2016-02-05 17:33:33 -05:00
parent 2389b95ee6
commit 0fa7f83270
2 changed files with 13 additions and 9 deletions

View File

@ -22,6 +22,10 @@ class SWFResponse(BaseResponse):
if not isinstance(parameter, int):
raise SWFSerializationException(parameter)
def _check_float(self, parameter):
if not isinstance(parameter, float):
raise SWFSerializationException(parameter)
def _check_none_or_string(self, parameter):
if parameter is not None:
self._check_string(parameter)
@ -120,13 +124,13 @@ class SWFResponse(BaseResponse):
if start_time_filter is None and close_time_filter is None:
raise SWFValidationException('Must specify time filter')
if start_time_filter:
self._check_int(start_time_filter['oldestDate'])
self._check_float(start_time_filter['oldestDate'])
if 'latestDate' in start_time_filter:
self._check_int(start_time_filter['latestDate'])
self._check_float(start_time_filter['latestDate'])
if close_time_filter:
self._check_int(close_time_filter['oldestDate'])
self._check_float(close_time_filter['oldestDate'])
if 'latestDate' in close_time_filter:
self._check_int(close_time_filter['latestDate'])
self._check_float(close_time_filter['latestDate'])
if tag_filter:
self._check_string(tag_filter['tag'])
if type_filter:
@ -168,9 +172,9 @@ class SWFResponse(BaseResponse):
self._check_exclusivity(executionFilter=execution_filter,
typeFilter=type_filter,
tagFilter=tag_filter)
self._check_int(start_time_filter['oldestDate'])
self._check_float(start_time_filter['oldestDate'])
if 'latestDate' in start_time_filter:
self._check_int(start_time_filter['latestDate'])
self._check_float(start_time_filter['latestDate'])
if tag_filter:
self._check_string(tag_filter['tag'])
if type_filter:

View File

@ -7,7 +7,7 @@ import sure # noqa
import tests.backport_assert_raises # noqa
from moto import mock_swf
from moto.core.utils import iso_8601_datetime_with_milliseconds
from moto.core.utils import unix_time
# Utils
@ -126,7 +126,7 @@ def test_list_open_workflow_executions():
run_id=run_id)
yesterday = datetime.now() - timedelta(days=1)
oldest_date = iso_8601_datetime_with_milliseconds(yesterday)
oldest_date = unix_time(yesterday)
response = conn.list_open_workflow_executions('test-domain',
oldest_date,
workflow_id='test-workflow')
@ -160,7 +160,7 @@ def test_list_closed_workflow_executions():
run_id=run_id)
yesterday = datetime.now() - timedelta(days=1)
oldest_date = iso_8601_datetime_with_milliseconds(yesterday)
oldest_date = unix_time(yesterday)
response = conn.list_closed_workflow_executions(
'test-domain',
start_oldest_date=oldest_date,