forked from gerardpuig/ubuntu-cleaner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increases UbuntuCleanerWindow coverage to 100%
The idea is to test UI simulating clicks e.g. `clicked()` and other events while mocking blocking calls like `run()` or `show()`.
- Loading branch information
1 parent
efcc958
commit 84d0d7c
Showing
1 changed file
with
19 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,29 @@ | ||
import mock | ||
import unittest | ||
|
||
from ubuntucleaner.main import UbuntuCleanerWindow | ||
|
||
|
||
class TestApp(unittest.TestCase): | ||
class TestUbuntuCleanerWindow(unittest.TestCase): | ||
def setUp(self): | ||
self.window = UbuntuCleanerWindow() | ||
with mock.patch("ubuntucleaner.main.Gtk.Window.show"): | ||
self.window = UbuntuCleanerWindow() | ||
|
||
def tearDown(self): | ||
del self.window | ||
|
||
def test_app(self): | ||
self.assertEqual(self.window.feature_dict, {'janitor': 0}) | ||
self.assertIsNotNone(self.window.aboutdialog) | ||
|
||
def tearDown(self): | ||
del self.window | ||
def test_on_about_button_clicked(self): | ||
with mock.patch("ubuntucleaner.main.Gtk.AboutDialog.run") as m_run: | ||
self.window.about_button.clicked() | ||
self.assertEqual(m_run.call_args_list, [mock.call()]) | ||
|
||
def test_on_mainwindow_destroy(self): | ||
with mock.patch("ubuntucleaner.main.Gtk.main_quit") as m_main_quit, \ | ||
mock.patch("ubuntucleaner.main.exit") as m_exit: | ||
self.window.mainwindow.destroy() | ||
self.assertEqual(m_main_quit.call_args_list, [mock.call()]) | ||
self.assertEqual(m_exit.call_args_list, [mock.call()]) |