def test_view_tasks_twitter_stream_listener_add_vote_for_question(self): load_fixture("tests/states.json", kind={"State": State}) load_fixture("tests/questions_no_votes.json", kind={"Question": Question, "State": State}) current_question = Question.get_current_question() assert len(current_question.state_scores) == 0 twitter_stream_listener = TwitterStreamListener() twitter_stream_listener.add_vote_for_question(0, 30, "CA", current_question) current_question = Question.get_current_question() assert len(current_question.state_scores) == 1 assert current_question.state_scores[0].state_abbreviation == "CA" assert current_question.state_scores[0].party_score_votes[0] == 1 assert current_question.state_scores[0].party_score_votes[1] == 0 assert current_question.state_scores[0].party_score_sway[0] == 30 assert current_question.state_scores[0].party_score_sway[1] == 0 twitter_stream_listener.add_vote_for_question(0, 50, "CA", current_question) twitter_stream_listener.add_vote_for_question(1, 20, "CA", current_question) assert current_question.state_scores[0].party_score_votes[0] == 2 assert current_question.state_scores[0].party_score_votes[1] == 1 assert current_question.state_scores[0].party_score_sway[0] == 80 assert current_question.state_scores[0].party_score_sway[1] == 20 twitter_stream_listener.add_vote_for_question(1, 30, "WA", current_question) assert len(current_question.state_scores) == 2 assert current_question.state_scores[1].state_abbreviation == "WA" assert current_question.state_scores[1].party_score_votes[0] == 0 assert current_question.state_scores[1].party_score_votes[1] == 1 assert current_question.state_scores[1].party_score_sway[0] == 0 assert current_question.state_scores[1].party_score_sway[1] == 30
def test_view_tasks_twitter_stream_listener_add_vote_for_question(self): load_fixture('tests/states.json', kind={'State': State}) load_fixture('tests/questions_no_votes.json', kind={'Question': Question,'State': State}) current_question = Question.get_current_question() assert len(current_question.state_scores) == 0 twitter_stream_listener = TwitterStreamListener() twitter_stream_listener.add_vote_for_question(0, 30, "CA", current_question) current_question = Question.get_current_question() assert len(current_question.state_scores) == 1 assert current_question.state_scores[0].state_abbreviation == "CA" assert current_question.state_scores[0].party_score_votes[0] == 1 assert current_question.state_scores[0].party_score_votes[1] == 0 assert current_question.state_scores[0].party_score_sway[0] == 30 assert current_question.state_scores[0].party_score_sway[1] == 0 twitter_stream_listener.add_vote_for_question(0, 50, "CA", current_question) twitter_stream_listener.add_vote_for_question(1, 20, "CA", current_question) assert current_question.state_scores[0].party_score_votes[0] == 2 assert current_question.state_scores[0].party_score_votes[1] == 1 assert current_question.state_scores[0].party_score_sway[0] == 80 assert current_question.state_scores[0].party_score_sway[1] == 20 twitter_stream_listener.add_vote_for_question(1, 30, "WA", current_question) assert len(current_question.state_scores) == 2 assert current_question.state_scores[1].state_abbreviation == "WA" assert current_question.state_scores[1].party_score_votes[0] == 0 assert current_question.state_scores[1].party_score_votes[1] == 1 assert current_question.state_scores[1].party_score_sway[0] == 0 assert current_question.state_scores[1].party_score_sway[1] == 30