From f366c6c0596610094c0053bb609099bb358888a9 Mon Sep 17 00:00:00 2001 From: Dan Palmer Date: Thu, 4 Jan 2018 14:12:00 +0000 Subject: [PATCH] Implement and test setup for feeds --- routemaster/feeds.py | 2 +- routemaster/tests/test_feeds.py | 71 +++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 routemaster/tests/test_feeds.py diff --git a/routemaster/feeds.py b/routemaster/feeds.py index ae0d9bf4..49227d0a 100644 --- a/routemaster/feeds.py +++ b/routemaster/feeds.py @@ -8,7 +8,7 @@ def feeds_for_state_machine(state_machine) -> Dict[str, 'Feed']: """Get a mapping of feed prefixes to unfetched feeds.""" - pass + return {x.name: Feed(x.url) for x in state_machine.feeds} class FeedNotFetched(Exception): diff --git a/routemaster/tests/test_feeds.py b/routemaster/tests/test_feeds.py new file mode 100644 index 00000000..a92991a5 --- /dev/null +++ b/routemaster/tests/test_feeds.py @@ -0,0 +1,71 @@ +import mock +import pytest +import httpretty + +from routemaster.feeds import Feed, FeedNotFetched, feeds_for_state_machine +from routemaster.config import Feed as FeedConfig +from routemaster.config import Gate, NoNextStates, StateMachine +from routemaster.exit_conditions import ExitConditionProgram + + +def test_feeds_for_state_machine(): + state_machine = StateMachine( + name='example', + feeds=[ + FeedConfig(name='test_feed', url='http://localhost/