diff options
author | Code Raguet <ignacio.code@gmail.com> | 2013-10-01 20:28:19 (GMT) |
---|---|---|
committer | Code Raguet <ignacio.code@gmail.com> | 2013-10-01 20:36:22 (GMT) |
commit | 70ee2f67e0772d36a0a5ca0ec957186820b26c43 (patch) | |
tree | 36393e52e1dd234394a188383f2b9e9259e695c2 | |
parent | 15b10d33512cddd7ec20ea80451c8c4fc49f6c50 (diff) |
refactor step "and_encuestador_is_binded_to_poll" to get poll_id by poll_name
-rw-r--r-- | webapp/webapp/features/steps.py | 4 | ||||
-rw-r--r-- | webapp/webapp/features/terrain.py | 6 | ||||
-rw-r--r-- | webapp/webapp/features/upload_poll_result.py | 18 |
3 files changed, 15 insertions, 13 deletions
diff --git a/webapp/webapp/features/steps.py b/webapp/webapp/features/steps.py index 67dc220..a36a069 100644 --- a/webapp/webapp/features/steps.py +++ b/webapp/webapp/features/steps.py @@ -80,8 +80,10 @@ def and_encuestador_is_binded_to_poll(step, encuestador, poll_name): pollster = get_pollster_by_username(encuestador) except IndexError: pollster = Pollster.create(username=username, password=password) - polls = [world.poll_id] + poll_id = get_poll_by_name(poll_name).id.__str__() + polls = [poll_id] Poll.pollster_assignment(pollster.id, polls) + world.poll_id = poll_id def get_fixture(poll_result): diff --git a/webapp/webapp/features/terrain.py b/webapp/webapp/features/terrain.py index 8a72da7..683b443 100644 --- a/webapp/webapp/features/terrain.py +++ b/webapp/webapp/features/terrain.py @@ -7,7 +7,7 @@ from fabric.context_managers import hide from django.conf import settings from django.core import management -from utils.test import remove_option_images_dir +from utils.test import remove_option_images_dir, empty_results_dir @before.all @@ -15,6 +15,7 @@ def set_browser(): world.browser = Browser('phantomjs') world.fixtures_path = os.path.join(settings.PROJECT_ROOT, 'features/fixtures') + create_results_dir() def create_results_dir(): @@ -22,7 +23,7 @@ def create_results_dir(): try: os.mkdir(dir_) except OSError: - print "\n INFO: {0} ya existe".format(dir_) + print "\n {0} ya existe".format(dir_) @after.all @@ -71,6 +72,7 @@ def before_each_feature(feature): """This is the main lettuce hook "@before.each_feature".""" drop_mongo() drop_sqlite() + empty_results_dir() if feature.name in ("Researcher adds images to options", "Researcher can't modify poll's structure", "Upload .poll_result files"): diff --git a/webapp/webapp/features/upload_poll_result.py b/webapp/webapp/features/upload_poll_result.py index 562b84a..b8a23af 100644 --- a/webapp/webapp/features/upload_poll_result.py +++ b/webapp/webapp/features/upload_poll_result.py @@ -1,21 +1,19 @@ # -*- coding: utf-8 -*- +import os + from lettuce import step, world from nose.tools import assert_true, assert_equals -from polls.models import Poll -from poll_result_details import (create_poll_result_file, - get_pollster_by_username) +from polls.models import Poll, PollResultFile @step(u'And "([^"]*)" is authored by "([^"]*)"') def result_file_is_authored_by_pollster(step, file_name, pollster_username): - pollster = get_pollster_by_username(pollster_username) - data = {} - data['poll_id'] = world.poll_id.__str__() - data['pollster_username'] = pollster.username - data['pollster_id'] = pollster.id.__str__() - data['result'] = {} - world.poll_result_path = create_poll_result_file(data, file_name) + fixtures_path = world.fixtures_path + file_path = os.path.join(fixtures_path, file_name) + rf = PollResultFile(file_path) + assert_equals(pollster_username, rf.get_pollster_username()) + world.poll_result_path = file_path @step(u'I upload "([^"]*)"') |