Beispiel #1
0
    def test_model_question(self):
        # Load fixtures
        load_fixture('tests/states.json', kind={'State': State})
        load_fixture('tests/questions.json', 
                        kind={'Question': Question,'State': State})
        question_entity = Question.get_current_question()

        # Check current question
        assert question_entity.key.id() == "q2"
        State.update_state_scores_for_completed_question(question_entity)
        Question.tally_college_and_vote_scores(question_entity)

        # NY and TX was a draw so random 2 votes will be added
        assert question_entity.vote_score[0] == (505 + 120 + 100 + 150) or \
                                                (505 + 120 + 100 + 150) + 1 or \
                                                (505 + 120 + 100 + 150) + 2
        assert question_entity.vote_score[1] == (510 + 240 + 100 + 150) or \
                                                (510 + 240 + 100 + 150) +1 or \
                                                (510 + 240 + 100 + 150) +2 

        # NY and TX was a draw so could go either way (29, 38)
        assert question_entity.college_score[0] == 0 or 29 or 38 or (29 + 38)
        assert question_entity.college_score[1] == (55 + 12) + 0  or \
                                                   (55 + 12) + 29 or \
                                                   (55 + 12) + 38 or \
                                                   (55 + 12) + (29 + 38)

        # Check get next questions
        question_entity = Question.get_next_question()
        assert question_entity.key.id() == "q3"

        # Check get last question start  time
        current_question_start_time = Question.get_current_question_start_time()
        current_question_start_time_string = str(current_question_start_time)
        assert current_question_start_time_string == "2016-01-23 00:00:00"
Beispiel #2
0
    def test_model_question_complete(self):
        # Load fixtures
        load_fixture('tests/questions_complete.json', 
                        kind={'Question': Question})

        # Check get next questions
        question_entity = Question.get_next_question()
        assert question_entity == None

        # Check get current question start  time
        current_question_start_time = Question.get_current_question_start_time()
        assert current_question_start_time == None
Beispiel #3
0
    def test_model_question_unstarted(self):
        # Load fixtures
        load_fixture('tests/questions_unstarted.json', 
                        kind={'Question': Question})

        # Check get next questions
        question_entity = Question.get_next_question()
        assert question_entity.key.id() == "q1"

        # Check get current question start time
        current_question_start_time = Question.get_current_question_start_time()
        assert current_question_start_time == None
Beispiel #4
0
    def test_model_question_complete(self):
        # Load fixtures
        load_fixture('tests/questions_complete.json',
                     kind={'Question': Question})

        # Check get next questions
        question_entity = Question.get_next_question()
        assert question_entity == None

        # Check get current question start  time
        current_question_start_time = Question.get_current_question_start_time(
        )
        assert current_question_start_time == None
Beispiel #5
0
    def test_model_question_unstarted(self):
        # Load fixtures
        load_fixture('tests/questions_unstarted.json',
                     kind={'Question': Question})

        # Check get next questions
        question_entity = Question.get_next_question()
        assert question_entity.key.id() == "q1"

        # Check get current question start time
        current_question_start_time = Question.get_current_question_start_time(
        )
        assert current_question_start_time == None
Beispiel #6
0
    def test_model_question(self):
        # Load fixtures
        load_fixture('tests/states.json', kind={'State': State})
        load_fixture('tests/questions.json',
                     kind={
                         'Question': Question,
                         'State': State
                     })
        question_entity = Question.get_current_question()

        # Check current question
        assert question_entity.key.id() == "q2"
        State.update_state_scores_for_completed_question(question_entity)
        Question.tally_college_and_vote_scores(question_entity)

        # NY and TX was a draw so random 2 votes will be added
        assert question_entity.vote_score[0] == (505 + 120 + 100 + 150) or \
                                                (505 + 120 + 100 + 150) + 1 or \
                                                (505 + 120 + 100 + 150) + 2
        assert question_entity.vote_score[1] == (510 + 240 + 100 + 150) or \
                                                (510 + 240 + 100 + 150) +1 or \
                                                (510 + 240 + 100 + 150) +2

        # NY and TX was a draw so could go either way (29, 38)
        assert question_entity.college_score[0] == 0 or 29 or 38 or (29 + 38)
        assert question_entity.college_score[1] == (55 + 12) + 0  or \
                                                   (55 + 12) + 29 or \
                                                   (55 + 12) + 38 or \
                                                   (55 + 12) + (29 + 38)

        # Check get next questions
        question_entity = Question.get_next_question()
        assert question_entity.key.id() == "q3"

        # Check get last question start  time
        current_question_start_time = Question.get_current_question_start_time(
        )
        current_question_start_time_string = str(current_question_start_time)
        assert current_question_start_time_string == "2016-01-23 00:00:00"