class TestAboutView: @pytest.fixture(autouse=True) def mock_external_classes(self, mocker): self.controller = mocker.Mock() mocker.patch.object(self.controller, 'maximum_popup_dimensions', return_value=(64, 64)) mocker.patch(VIEWS + '.urwid.SimpleFocusListWalker', return_value=[]) server_version, server_feature_level = MINIMUM_SUPPORTED_SERVER_VERSION self.about_view = AboutView(self.controller, 'About', zt_version=ZT_VERSION, server_version=server_version, server_feature_level=server_feature_level, theme_name='zt_dark', color_depth=256, autohide_enabled=False, footlink_enabled=True) @pytest.mark.parametrize('key', {*keys_for_command('GO_BACK'), *keys_for_command('ABOUT')}) def test_keypress_exit_popup(self, key, widget_size): size = widget_size(self.about_view) self.about_view.keypress(size, key) assert self.controller.exit_popup.called def test_keypress_exit_popup_invalid_key(self, widget_size): key = 'a' size = widget_size(self.about_view) self.about_view.keypress(size, key) assert not self.controller.exit_popup.called 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.about_view) super_keypress = mocker.patch(VIEWS + '.urwid.ListBox.keypress') self.about_view.keypress(size, key) super_keypress.assert_called_once_with(size, expected_key) def test_feature_level_content(self, mocker, zulip_version): self.controller = mocker.Mock() mocker.patch.object(self.controller, 'maximum_popup_dimensions', return_value=(64, 64)) mocker.patch(VIEWS + '.urwid.SimpleFocusListWalker', return_value=[]) server_version, server_feature_level = zulip_version about_view = AboutView(self.controller, 'About', zt_version=ZT_VERSION, server_version=server_version, server_feature_level=server_feature_level, theme_name='zt_dark', color_depth=256, autohide_enabled=False, footlink_enabled=True) assert len(about_view.feature_level_content) == ( 1 if server_feature_level else 0 )
class TestAboutView: @pytest.fixture(autouse=True) def mock_external_classes(self, mocker): self.controller = mocker.Mock() mocker.patch.object( self.controller, "maximum_popup_dimensions", return_value=(64, 64) ) mocker.patch(LISTWALKER, return_value=[]) server_version, server_feature_level = MINIMUM_SUPPORTED_SERVER_VERSION self.about_view = AboutView( self.controller, "About", zt_version=ZT_VERSION, server_version=server_version, server_feature_level=server_feature_level, theme_name="zt_dark", color_depth=256, notify_enabled=False, autohide_enabled=False, maximum_footlinks=3, ) @pytest.mark.parametrize( "key", {*keys_for_command("GO_BACK"), *keys_for_command("ABOUT")} ) def test_keypress_exit_popup(self, key, widget_size): size = widget_size(self.about_view) self.about_view.keypress(size, key) assert self.controller.exit_popup.called def test_keypress_exit_popup_invalid_key(self, widget_size): key = "a" size = widget_size(self.about_view) self.about_view.keypress(size, key) assert not self.controller.exit_popup.called 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.about_view) super_keypress = mocker.patch(MODULE + ".urwid.ListBox.keypress") self.about_view.keypress(size, key) super_keypress.assert_called_once_with(size, expected_key) def test_feature_level_content(self, mocker, zulip_version): self.controller = mocker.Mock() mocker.patch.object( self.controller, "maximum_popup_dimensions", return_value=(64, 64) ) mocker.patch(LISTWALKER, return_value=[]) server_version, server_feature_level = zulip_version about_view = AboutView( self.controller, "About", zt_version=ZT_VERSION, server_version=server_version, server_feature_level=server_feature_level, theme_name="zt_dark", color_depth=256, notify_enabled=False, autohide_enabled=False, maximum_footlinks=3, ) assert len(about_view.feature_level_content) == ( 1 if server_feature_level else 0 )