Exemplo n.º 1
0
class TestStreamMembersView:
    @pytest.fixture(autouse=True)
    def mock_external_classes(self, mocker, monkeypatch):
        self.controller = mocker.Mock()
        mocker.patch.object(self.controller,
                            'maximum_popup_dimensions',
                            return_value=(64, 64))
        self.controller.model.get_other_subscribers_in_stream.return_value = []
        self.controller.model.user_full_name = ''
        mocker.patch(VIEWS + ".urwid.SimpleFocusListWalker", return_value=[])
        stream_id = 10
        self.stream_members_view = StreamMembersView(self.controller,
                                                     stream_id)

    @pytest.mark.parametrize(
        'key',
        {*keys_for_command('GO_BACK'), *keys_for_command('STREAM_MEMBERS')})
    def test_keypress_exit_popup(self, key, widget_size):
        stream_id = self.stream_members_view.stream_id
        size = widget_size(self.stream_members_view)
        self.stream_members_view.keypress(size, key)
        self.controller.show_stream_info.assert_called_once_with(
            stream_id=stream_id, )

    def test_keypress_navigation(self, mocker, widget_size,
                                 navigation_key_expected_key_pair):
        key, expected_key = navigation_key_expected_key_pair
        size = widget_size(self.stream_members_view)
        super_keypress = mocker.patch(VIEWS + '.urwid.ListBox.keypress')
        self.stream_members_view.keypress(size, key)
        super_keypress.assert_called_once_with(size, expected_key)
Exemplo n.º 2
0
 def mock_external_classes(self, mocker, monkeypatch):
     self.controller = mocker.Mock()
     mocker.patch.object(self.controller, 'maximum_popup_dimensions',
                         return_value=(64, 64))
     self.controller.model.get_other_subscribers_in_stream.return_value = []
     self.controller.model.user_full_name = ''
     mocker.patch(VIEWS + ".urwid.SimpleFocusListWalker", return_value=[])
     stream_id = 10
     self.stream_members_view = StreamMembersView(
         self.controller, stream_id)
Exemplo n.º 3
0
 def mock_external_classes(self, mocker, monkeypatch):
     self.controller = mocker.Mock()
     mocker.patch.object(
         self.controller, "maximum_popup_dimensions", return_value=(64, 64)
     )
     self.controller.model.get_other_subscribers_in_stream.return_value = []
     self.controller.model.user_full_name = ""
     mocker.patch(LISTWALKER, return_value=[])
     stream_id = 10
     self.stream_members_view = StreamMembersView(self.controller, stream_id)
Exemplo n.º 4
0
 def show_stream_members(self, stream_id: int) -> None:
     stream_members_view = StreamMembersView(self, stream_id)
     self.show_pop_up(stream_members_view, 'area:stream')