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
07bab620
Commit
07bab620
authored
5 years ago
by
Nico
Browse files
Options
Downloads
Patches
Plain Diff
Re-enable pytest in GitLab CI
parent
1c32121f
No related branches found
No related tags found
1 merge request
!35
Re-enable tests on GitLab CI; delete tests of private methods
Pipeline
#4415
passed
5 years ago
Stage: test
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitlab-ci.yml
+2
-2
2 additions, 2 deletions
.gitlab-ci.yml
briar-gtk/tests/briar_gtk/test_application.py
+1
-93
1 addition, 93 deletions
briar-gtk/tests/briar_gtk/test_application.py
briar-gtk/tests/conftest.py
+0
-28
0 additions, 28 deletions
briar-gtk/tests/conftest.py
with
3 additions
and
123 deletions
.gitlab-ci.yml
+
2
−
2
View file @
07bab620
...
...
@@ -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
This diff is collapsed.
Click to expand it.
briar-gtk/tests/briar_gtk/test_application.py
+
1
−
93
View file @
07bab620
...
...
@@ -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
"
)
This diff is collapsed.
Click to expand it.
briar-gtk/tests/conftest.py
+
0
−
28
View file @
07bab620
# 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
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