type error handling - test correction. investigate how it pass on <py3.8
@@ -139,7 +139,7 @@ class TestFilters:
storage_client_mock = MagicMock(StorageClientAsync)
cf_mgr = ConfigurationManager(storage_client_mock)
- filter_result = {'count': 1, 'rows': []}
+ filter_result = {'count': 0, 'rows': []}
# Changed in version 3.8: patch() now returns an AsyncMock if the target is an async function.
if sys.version_info.major == 3 and sys.version_info.minor >= 8:
@@ -191,19 +191,15 @@ class TestFilters:
get_cat_info_patch.assert_called_once_with(filter_name)
async def test_get_filter_by_name_type_error(self, client):
+ # What cause a TypeError https://github.com/fledge-iot/fledge/blob/develop/python/fledge/services/core/api/filters.py#L319
storage_client_mock = MagicMock(StorageClientAsync)
- # Changed in version 3.8: patch() now returns an AsyncMock if the target is an async function.
- if sys.version_info.major == 3 and sys.version_info.minor >= 8:
- _rv = await self.async_mock(0)
- else:
- _rv = asyncio.ensure_future(self.async_mock(0))
-
filter_name = "AssetFilter"
cf_mgr = ConfigurationManager(storage_client_mock)
with patch.object(connect, 'get_storage_async', return_value=storage_client_mock):
- with patch.object(cf_mgr, 'get_category_all_items', return_value=(_rv)) as get_cat_info_patch:
+ with patch.object(cf_mgr, 'get_category_all_items', side_effect=TypeError) as get_cat_info_patch:
resp = await client.get('/fledge/filter/{}'.format(filter_name))
assert 400 == resp.status
+ # assert "?" == resp.reason
get_cat_info_patch.assert_called_once_with(filter_name)
async def test_get_filter_by_name_exception(self, client):
