Beispiel #1
0
    def test_draw_without_legend(self, monkeypatch):
        cue = Survey(self.name, self.message, self.scale, self.fields)
        right = cue.keys.get('right')
        left = cue.keys.get('left')
        enter = cue.keys.get('enter')

        def generic_return_none(*args, **kwargs):
            return None

        moves = [
            right, right, left, left, left, left, left, right, right, enter,
            enter, enter, enter, enter
        ]

        def mock_listen_for_key():
            if moves:
                return moves.pop(0)

        monkeypatch.setattr(cursor, 'write', generic_return_none)
        monkeypatch.setattr(cursor, 'move', generic_return_none)
        monkeypatch.setattr(cue, 'listen_for_key', mock_listen_for_key)

        responses = {}
        for field in self.fields:
            responses.update({field['name']: self.scale[2]})
        assert cue._draw() is None
        assert cue.answer == {self.name: responses}
Beispiel #2
0
 def test__init__errors(self):
     with pytest.raises(TypeError):
         Survey(1, self.message, self.scale, self.fields)
     with pytest.raises(TypeError):
         Survey(self.name, 1, self.scale, self.fields)
     with pytest.raises(TypeError):
         Survey(self.name, self.message, 1, self.fields)
     with pytest.raises(TypeError):
         Survey(self.name, self.message, self.scale, 1)
Beispiel #3
0
    def test_init(self):
        cue = Survey(self.name, self.message, self.scale, self.fields)

        assert cue._name == self.name
        assert cue._message == self.message

        assert cue._scale == self.scale
        assert cue._fields == self.fields
Beispiel #4
0
    def test_from_dict(self):
        cue = Survey.from_dict(self.dic)

        assert cue._name == self.name
        assert cue._message == self.message

        assert cue._scale == self.scale
        assert cue._fields == self.fields
Beispiel #5
0
    def test_init_with_legend_two(self):
        cue = Survey(self.name, self.message, self.scale, self.fields,
                     self.legend_two)

        assert cue._name == self.name
        assert cue._message == self.message

        assert cue._scale == self.scale
        assert cue._fields == self.fields
        assert cue._legend == self.legend_two
Beispiel #6
0
    def test_init_with_scale_with_equal_descs(self):
        cue = Survey(self.name, self.message, self.scale_with_equal_descs,
                     self.fields)

        assert cue._name == self.name
        assert cue._message == self.message

        assert cue._scale == list(self.scale_with_equal_descs)
        assert cue._fields == self.fields
        assert cue._legend == list(self.scale_with_equal_descs.values())
Beispiel #7
0
    def test_send(self, monkeypatch):
        cue = Survey(self.name, self.message, self.scale, self.fields)

        monkeypatch.setattr(cue, '_draw', lambda: None)
        assert cue.answer is None