Skip to content

Commit

Permalink
Merge 84974e0 into 29292b3
Browse files Browse the repository at this point in the history
  • Loading branch information
exxamalte committed Jan 20, 2020
2 parents 29292b3 + 84974e0 commit b22cb24
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions aio_georss_client/feed.py
Expand Up @@ -82,6 +82,7 @@ async def update(self) -> Tuple[str, Optional[List[T_FEED_ENTRY]]]:
return UPDATE_OK_NO_DATA, None
else:
# Error happened while fetching the feed.
self._last_timestamp = None
return UPDATE_ERROR, None

async def _fetch(self,
Expand Down
34 changes: 34 additions & 0 deletions tests/test_feed.py
Expand Up @@ -301,6 +301,40 @@ async def test_update_error(aresponses, event_loop):
"http://test.url/badpath")
status, entries = await feed.update()
assert status == UPDATE_ERROR
assert feed.last_timestamp is None


@pytest.mark.asyncio
async def test_update_ok_then_error(aresponses, event_loop):
"""Test updating feed goes fine, followed by an error."""
aresponses.add(
"test.url",
"/testpath",
"get",
aresponses.Response(text=load_fixture('generic_feed_1.xml'),
status=200),
)

async with aiohttp.ClientSession(loop=event_loop) as websession:

feed = MockGeoRssFeed(websession, HOME_COORDINATES_1,
"http://test.url/testpath")
assert repr(feed) == "<MockGeoRssFeed(home=(-31.0, 151.0), " \
"url=http://test.url/testpath, radius=None, " \
"categories=None)>"
status, entries = await feed.update()
assert status == UPDATE_OK
assert entries is not None
assert len(entries) == 5
assert feed.last_timestamp is not None

aresponses.add(
"test.url", "/testpath", "get", aresponses.Response(status=404)
)

status, entries = await feed.update()
assert status == UPDATE_ERROR
assert feed.last_timestamp is None


@pytest.mark.asyncio
Expand Down

0 comments on commit b22cb24

Please sign in to comment.