diff options
author | Code Raguet <ignacio.code@gmail.com> | 2013-09-11 17:16:58 (GMT) |
---|---|---|
committer | Code Raguet <ignacio.code@gmail.com> | 2013-09-11 22:40:52 (GMT) |
commit | 126a12c9382b21aa2d3009b1ebfa7c92a1207cb8 (patch) | |
tree | e40121da475b0e5a0171c2b50609a53ab6718774 /webapp/webapp/features | |
parent | 371a2d4d473bdac5408bfa15a3ff86125e1f34ac (diff) |
Add feature for issue 4231: remove poll results
Diffstat (limited to 'webapp/webapp/features')
-rw-r--r-- | webapp/webapp/features/remove_poll_results_from_poll.feature | 11 | ||||
-rw-r--r-- | webapp/webapp/features/remove_poll_results_from_poll.py | 41 |
2 files changed, 52 insertions, 0 deletions
diff --git a/webapp/webapp/features/remove_poll_results_from_poll.feature b/webapp/webapp/features/remove_poll_results_from_poll.feature new file mode 100644 index 0000000..9447e36 --- /dev/null +++ b/webapp/webapp/features/remove_poll_results_from_poll.feature @@ -0,0 +1,11 @@ +Feature: Administrator removes all .poll_results from a poll + As an administrator + I want to empty (reset) a poll from results + So that the poll get fresh for new .poll_results + + Scenario: A poll with .poll_results + Given I am logged in as "Administrator" + And "poll_with_results" exists + And "poll_with_results" has "simple.poll_result" + When I visit the "Edit" page for "poll_with_results" poll + And click on "Eliminar resultados" diff --git a/webapp/webapp/features/remove_poll_results_from_poll.py b/webapp/webapp/features/remove_poll_results_from_poll.py new file mode 100644 index 0000000..a82497b --- /dev/null +++ b/webapp/webapp/features/remove_poll_results_from_poll.py @@ -0,0 +1,41 @@ +import json + +from lettuce import step, world + +from steps import login, get_fixture, create_poll_result_file +from polls.models import Poll + + +@step(u'Given I am logged in as "([^"]*)"') +def given_i_am_logged_in_as_rol(step, rol): + roles2generic_users = { + 'Administrator': 'admin' + } + browser = world.browser + username = roles2generic_users[rol] + password = username + login(browser, username, password) + + +@step(u'And "([^"]*)" has "([^"]*)"') +def and_poll_has_poll_result(step, poll_name, poll_result_name): + poll_result_path = get_fixture(poll_result_name) + poll_id = world.poll_id.__str__() + + with open(poll_result_path) as f: + poll_result_data = json.load(f, "utf-8") + poll_result_data['poll_id'] = poll_id + poll_result_data['pollster_username'] = "encuestador" + poll_result_data['pollster_id'] = '1' + poll_result_path = create_poll_result_file(poll_result_data, + poll_result_name) + + poll = Poll.get(poll_id) + path_and_name = (poll_result_path, poll_result_name) + poll.add_result_files([path_and_name]) + + +@step(u'And click on "([^"]*)"') +def and_click_on_text(step, text): + b = world.browser + b.click_link_by_text(text) |