diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 689f48e650fafc4562e4dba1f83a82bc1ae393d0..ec49c31d5ad00b2368b2a80558e3965691d7c8e3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,10 +2,11 @@ # SPDX-License-Identifier: AGPL-3.0-only # License-Filename: LICENSE.md -image: debian:buster +image: debian:buster-backports before_script: - apt update && apt install --no-install-recommends -y gir1.2-gtk-3.0 python3-gi python3-pip python3-setuptools + - apt install --no-install-recommends -y -t buster-backports libhandy-0.0-dev - pip3 install -r requirements-dev.txt stages: @@ -23,4 +24,3 @@ pytest: stage: test coverage: '/TOTAL.*\s+(\d+%)$/' script: tools/tests/test-pytest.sh - when: manual diff --git a/briar-gtk/tests/briar_gtk/test_application.py b/briar-gtk/tests/briar_gtk/test_application.py index 448e46e17990724d7038b7b3c4c3328452b1de6f..ddb1df6a581392e2b3c559ec85917f75efe1a9d8 100644 --- a/briar-gtk/tests/briar_gtk/test_application.py +++ b/briar-gtk/tests/briar_gtk/test_application.py @@ -37,7 +37,7 @@ def test_do_activate(mocker): _setup_window_mock.assert_called_once() -def test_quit(mocker): +def test_do_shutdown(mocker): api_mock = mocker.patch("briar_wrapper.api.Api") api_stop_mock = mocker.patch("briar_wrapper.api.Api.stop") window_mock = mocker.patch("briar_gtk.window.Window") @@ -54,95 +54,3 @@ def test_quit(mocker): api_stop_mock.assert_called_once() window_hide_mock.assert_called_once() do_shutdown_mock.assert_called_once() - - -def test_set_application_name(mocker): - set_application_name_mock = mocker.patch( - "gi.repository.GLib.set_application_name") - set_prgname_mock = mocker.patch("gi.repository.GLib.set_prgname") - name_mock = "Mock" - - Application._set_application_name(name_mock) - - set_application_name_mock.assert_called_once_with(name_mock) - set_prgname_mock.assert_called_once_with(name_mock) - - -def test_set_application_name_implicit(mocker): - set_application_name_mock = mocker.patch( - "gi.repository.GLib.set_application_name") - set_prgname_mock = mocker.patch("gi.repository.GLib.set_prgname") - - Application() - - set_application_name_mock.assert_called_once_with(APPLICATION_NAME) - set_prgname_mock.assert_called_once_with(APPLICATION_NAME) - - -def test_setup_styling(mocker): - new_for_uri_mock = mocker.patch("gi.repository.Gio.File.new_for_uri") - load_from_file_mock = mocker.patch( - "gi.repository.Gtk.CssProvider.load_from_file") - get_default_mock = mocker.patch("gi.repository.Gdk.Screen.get_default") - add_provider_for_screen_mock = mocker.patch( - "gi.repository.Gtk.StyleContext.add_provider_for_screen") - - Application._setup_styling(APPLICATION_STYLING_PATH) - - new_for_uri_mock.assert_called_with(APPLICATION_STYLING_PATH) - load_from_file_mock.assert_called_once() - get_default_mock.assert_called_once() - add_provider_for_screen_mock.assert_called_once() - - -def test_setup_api(mocker): - application = Application() - - assert not hasattr(application, "api") - - application._setup_api() - - assert isinstance(application.api, Api) - assert application.api._command == ["java", "-jar", BRIAR_HEADLESS_JAR] - - -def test_setup_window(mocker): - mocker.patch("briar_gtk.window.Window.__init__").return_value = None - window_show_mock = mocker.patch("briar_gtk.window.Window.show") - window_present_mock = mocker.patch("briar_gtk.window.Window.present") - - Application()._setup_window() - - window_show_mock.assert_called_once() - window_present_mock.assert_called_once() - - -def test_setup_window_has_attribute(mocker): - mocker.patch("briar_gtk.window.Window.__init__").return_value = None - window_mock = Mock() - - application = Application() - application.window = window_mock - - application._setup_window() - - window_mock.show.assert_not_called() - window_mock.present.assert_called_once() - - -def test_setup_window_has_none_attribute(mocker): - mocker.patch("briar_gtk.window.Window.__init__").return_value = None - window_show_mock = mocker.patch("briar_gtk.window.Window.show") - window_present_mock = mocker.patch("briar_gtk.window.Window.present") - - application = Application() - - application._setup_window() - - window_show_mock.assert_called_once() - window_present_mock.assert_called_once() - - -@pytest.fixture(autouse=True) -def glib_set_application_name(mocker): - mocker.patch("gi.repository.GLib.set_application_name") diff --git a/briar-gtk/tests/conftest.py b/briar-gtk/tests/conftest.py index 3fad9dbbfa1dbf2d63ddf4a217866fe8741417ad..bb0bffd0ae3d8ece3a0467e712e8f611728d62b2 100644 --- a/briar-gtk/tests/conftest.py +++ b/briar-gtk/tests/conftest.py @@ -1,31 +1,3 @@ # Copyright (c) 2019 Nico Alt # SPDX-License-Identifier: AGPL-3.0-only # License-Filename: LICENSE.md - -from random import choice -from string import ascii_letters, digits -from unittest import mock - -import pytest - -# pylint: disable=redefined-outer-name - - -@pytest.fixture -def api(auth_token): - api = mock.Mock() - api.auth_token = auth_token - return api - - -@pytest.fixture -def auth_token(): - return ''.join(choice(ascii_letters + digits) for i in range(33)) - - -@pytest.fixture -def request_headers(auth_token): - request_headers = { - "Authorization": 'Bearer %s' % auth_token - } - return request_headers