Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Briar GTK
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
briar
Briar GTK
Commits
397cf6c2
Commit
397cf6c2
authored
5 years ago
by
Nico
Browse files
Options
Downloads
Patches
Plain Diff
Add unit tests for Briar's Application
parent
09eafd1c
No related branches found
No related tags found
No related merge requests found
Pipeline
#3690
passed
5 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
requirements-dev.txt
+1
-0
1 addition, 0 deletions
requirements-dev.txt
src/briar/gtk/application.py
+4
-4
4 additions, 4 deletions
src/briar/gtk/application.py
tests/briar/gtk/test_application.py
+97
-0
97 additions, 0 deletions
tests/briar/gtk/test_application.py
with
102 additions
and
4 deletions
requirements-dev.txt
+
1
−
0
View file @
397cf6c2
...
@@ -7,4 +7,5 @@ pycodestyle>=2.5.0
...
@@ -7,4 +7,5 @@ pycodestyle>=2.5.0
pylint>=2.3.1
pylint>=2.3.1
pytest>=4.6.2
pytest>=4.6.2
pytest-cov>=2.7.1
pytest-cov>=2.7.1
pytest-mock>=1.11.0
requests_mock>=1.6.0
requests_mock>=1.6.0
This diff is collapsed.
Click to expand it.
src/briar/gtk/application.py
+
4
−
4
View file @
397cf6c2
...
@@ -18,7 +18,7 @@ from briar.gtk.window import Window
...
@@ -18,7 +18,7 @@ from briar.gtk.window import Window
class
Application
(
Gtk
.
Application
):
class
Application
(
Gtk
.
Application
):
def
__init__
(
self
):
def
__init__
(
self
):
Application
.
_set_application_name
()
Application
.
_set_application_name
(
APPLICATION_NAME
)
super
().
__init__
(
application_id
=
APPLICATION_ID
)
super
().
__init__
(
application_id
=
APPLICATION_ID
)
# pylint: disable=arguments-differ
# pylint: disable=arguments-differ
...
@@ -38,9 +38,9 @@ class Application(Gtk.Application):
...
@@ -38,9 +38,9 @@ class Application(Gtk.Application):
Gio
.
Application
.
quit
(
self
)
Gio
.
Application
.
quit
(
self
)
@staticmethod
@staticmethod
def
_set_application_name
():
def
_set_application_name
(
name
):
GLib
.
set_application_name
(
APPLICATION_NAME
)
GLib
.
set_application_name
(
name
)
GLib
.
set_prgname
(
APPLICATION_NAME
)
GLib
.
set_prgname
(
name
)
@staticmethod
@staticmethod
def
_setup_styling
():
def
_setup_styling
():
...
...
This diff is collapsed.
Click to expand it.
tests/briar/gtk/test_application.py
0 → 100644
+
97
−
0
View file @
397cf6c2
# Copyright (c) 2019 Nico Alt
# SPDX-License-Identifier: AGPL-3.0-only
# License-Filename: LICENSE.md
import
gi
import
briar
from
briar.api.api
import
Api
from
briar.gtk.application
import
Application
from
briar.gtk.define
import
APPLICATION_NAME
,
BRIAR_HEADLESS_JAR
from
briar.gtk.window
import
Window
def
test_do_startup
(
mocker
):
do_startup_mock
=
mocker
.
patch
(
"
gi.repository.Gtk.Application.do_startup
"
)
_setup_styling_mock
=
mocker
.
patch
(
"
briar.gtk.application.Application._setup_styling
"
)
_setup_api_mock
=
mocker
.
patch
(
"
briar.gtk.application.Application._setup_api
"
)
Application
().
do_startup
()
do_startup_mock
.
assert_called_once
()
_setup_styling_mock
.
assert_called_once
()
_setup_api_mock
.
assert_called_once
()
def
test_do_activate
(
mocker
):
_setup_window_mock
=
mocker
.
patch
(
"
briar.gtk.application.Application._setup_window
"
)
Application
().
do_activate
()
_setup_window_mock
.
assert_called_once
()
def
test_quit
(
mocker
):
api_mock
=
mocker
.
patch
(
"
briar.api.api.Api
"
)
api_stop_mock
=
mocker
.
patch
(
"
briar.api.api.Api.stop
"
)
window_mock
=
mocker
.
patch
(
"
briar.gtk.window.Window
"
)
window_hide_mock
=
mocker
.
patch
(
"
briar.gtk.window.Window.hide
"
)
quit_mock
=
mocker
.
patch
(
"
gi.repository.Gio.Application.quit
"
)
application
=
Application
()
application
.
api
=
api_mock
application
.
window
=
window_mock
application
.
quit
()
api_stop_mock
.
assert_called_once
()
window_hide_mock
.
assert_called_once
()
quit_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
)
# TODO: How to assert that Api got initialized?
def
disabled_test_setup_api
(
mocker
):
api_mock
=
mocker
.
patch
(
"
briar.api.api.Api
"
)
application
=
Application
()
application
.
_setup_api
()
api_mock
.
assert_called_once_with
(
BRIAR_HEADLESS_JAR
)
assert
application
.
api
==
api_mock
# TODO: How to mock Window?
def
disabled_test_setup_window
(
mocker
):
window_mock
=
mocker
.
patch
(
"
briar.gtk.window.Window
"
)
window_show_mock
=
mocker
.
patch
(
"
briar.gtk.window.Window.show
"
)
Application
().
_setup_window
()
window_show_mock
.
assert_called_once
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment