Exemplo n.º 1
0
 def test9_double_user_response(self):
     nback = NBackGame(n_back=1, char_generator=fixed_chars('X')).start()
     nback.next_char()  # Warmup
     nback.next_char()
     nback.user_match()
     nback.user_match()
     nback.user_no_match()
     assert_score(nback, correct_match=1)
Exemplo n.º 2
0
    def test54_user_interaction_during_warmup_is_ignored(self):
        nback = NBackGame(n_back=2,
                          char_generator=fixed_chars("AXCXE")).start()

        nback.next_char()
        nback.user_match()
        assert_score(nback, 0, 0, 0, 0)

        nback.next_char()
        nback.user_no_match()
        assert_score(nback, 0, 0, 0, 0)
        score_sanity_check(nback)
Exemplo n.º 3
0
    def test51_user_correct_interaction(self):
        nback = NBackGame(n_back=2,
                          char_generator=fixed_chars("AXCXE")).start()

        nback.next_char()
        nback.next_char()
        nback.next_char()
        nback.user_no_match()
        assert_score(nback, 0, 0, 1, 0)

        nback.next_char()
        nback.user_match()
        assert_score(nback, 1, 0, 1, 0)

        nback.next_char()
        nback.user_no_match()
        assert_score(nback, 1, 0, 2, 0)
Exemplo n.º 4
0
    def test52_user_wrong_interaction(self):
        nback = NBackGame(n_back=2,
                          char_generator=fixed_chars("AXCXE")).start()

        nback.next_char()
        nback.next_char()
        nback.next_char()
        nback.user_match()
        assert_score(nback, 0, 1, 0, 0)

        nback.next_char()
        nback.user_no_match()
        assert_score(nback, 0, 1, 0, 1)

        nback.next_char()
        nback.user_match()
        assert_score(nback, 0, 2, 0, 1)

        score_sanity_check(nback)
Exemplo n.º 5
0
    def testA_callbacks(self):
        schedule = MagicMock()
        show_symbol = MagicMock()
        show_score = MagicMock()

        nback = NBackGame(n_back=1,
                          char_generator=fixed_chars('AABBCD'),
                          show_symbol=show_symbol,
                          show_score=show_score,
                          schedule=schedule).start()
        hide_call = call(nback.show_symbol_interval, nback.hide_symbol)
        next_call = call(nback.next_symbol_interval, nback.next_char)

        show_symbol.assert_not_called()
        nback.next_char()
        show_symbol.assert_called_once_with('A')
        schedule.assert_has_calls([hide_call, next_call])

        nback.next_char()
        show_symbol.assert_called_with('A')
        schedule.assert_has_calls([hide_call, next_call] * 2)
        nback.user_match()
        show_score.assert_called_once_with(correct_match=1,
                                           correct_no_match=0,
                                           wrong_match=0,
                                           wrong_no_match=0,
                                           no_response=0)

        nback.next_char()
        show_symbol.assert_called_with('B')
        schedule.assert_has_calls([hide_call, next_call] * 3)
        nback.user_no_match()
        show_score.assert_called_with(correct_match=1,
                                      correct_no_match=1,
                                      wrong_match=0,
                                      wrong_no_match=0,
                                      no_response=0)

        # Display no response as "wrong"
        nback.next_char()
        show_symbol.assert_called_with('B')
        nback.next_char()
        show_symbol.assert_called_with('C')
        show_score.assert_called_with(correct_match=1,
                                      correct_no_match=1,
                                      wrong_match=0,
                                      wrong_no_match=0,
                                      no_response=1)

        nback.next_char()
        show_symbol.assert_called_with('D')
        show_score.assert_called_with(correct_match=1,
                                      correct_no_match=1,
                                      wrong_match=0,
                                      wrong_no_match=0,
                                      no_response=2)
        nback.user_match()
        show_score.assert_called_with(correct_match=1,
                                      correct_no_match=1,
                                      wrong_match=1,
                                      wrong_no_match=0,
                                      no_response=2)
Exemplo n.º 6
0
    def test8_nback(self):
        nback = NBackGame(n_back=1,
                          char_generator=fixed_chars("CCCCDE")).start()
        nback.next_char()  # Warmup
        nback.next_char()
        nback.user_match()
        nback.next_char()
        nback.user_match()
        nback.next_char()
        nback.user_match()
        nback.next_char()
        nback.user_no_match()
        nback.next_char()
        nback.user_no_match()
        assert_score(nback, 3, 0, 2, 0)

        nback = NBackGame(n_back=2,
                          char_generator=fixed_chars("CCCCDE")).start()
        nback.next_char()  # Warmup
        nback.next_char()  # Warmup
        nback.next_char()
        nback.user_match()
        nback.next_char()
        nback.user_match()
        nback.next_char()
        nback.user_no_match()
        nback.next_char()
        nback.user_no_match()
        assert_score(nback, 2, 0, 2, 0)

        nback = NBackGame(n_back=3,
                          char_generator=fixed_chars("CCCCDE")).start()
        nback.next_char()  # Warmup
        nback.next_char()  # Warmup
        nback.next_char()  # Warmup
        nback.next_char()
        nback.user_match()
        nback.next_char()
        nback.user_no_match()
        nback.next_char()
        nback.user_no_match()
        assert_score(nback, 1, 0, 2, 0)