diff options
author | Rogelio Mita <rogeliomita@activitycentral.com> | 2013-09-10 14:53:44 (GMT) |
---|---|---|
committer | Rogelio Mita <rogeliomita@activitycentral.com> | 2013-09-10 14:53:44 (GMT) |
commit | ca6d7767175935a00c8392589fa65ba1286cf97e (patch) | |
tree | aa4ac770ccef6c6ce41d37292a3f1ffd966a0d06 | |
parent | 143ca51c52e65256eedbe5ca183631478a60ab07 (diff) |
Refactor: "Visit page for poll" step
-rw-r--r-- | webapp/webapp/features/steps.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/webapp/webapp/features/steps.py b/webapp/webapp/features/steps.py index fb398d4..5f57673 100644 --- a/webapp/webapp/features/steps.py +++ b/webapp/webapp/features/steps.py @@ -116,11 +116,19 @@ def i_should_see_a_message_that_says_text(step, text): assert_true(b.is_text_present(text)) +def get_poll_by_name(poll_name): + return filter(lambda p: p.name == poll_name, Poll.all())[0] + + @step(u'When I visit the "([^"]*)" page for "([^"]*)" poll') def visit_page_for_poll(step, page_name, poll_name): - page_list = {'Resultados': 'results'} - page = page_list[page_name] - poll_id = world.poll_id.__str__() + poll_id = getattr(world, "poll_id", None) + poll_id = str(poll_id) if poll_id else str(get_poll_by_name(poll_name).id) + page_list = { + 'Resultados': [poll_id, 'results'], + 'Modificar estructura': ['structure', poll_id] + } + page_args = page_list[page_name] b = world.browser - url = '/manager/polls/{poll_id}/{page}/'.format(poll_id=poll_id, page=page) + url = '/manager/polls/' + "/".join(page_args) b.visit(django_url(url)) |