Skip to content

Commit

Permalink
Increases UbuntuCleanerWindow coverage to 100%
Browse files Browse the repository at this point in the history
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
AndreMiras committed Dec 28, 2019
1 parent efcc958 commit 84d0d7c
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions tests/test_app.py
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()])

0 comments on commit 84d0d7c

Please sign in to comment.