From 956342478a8c68cc48b0f58681cb1c6eeb9477e1 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Fri, 8 Dec 2017 09:28:48 +1300 Subject: [PATCH] move subiquity.ui.views.tests.helpers to subiquitycore.testing.view_helpers --- .../ui/views/filesystem/tests/test_guided.py | 17 +++++++++-------- subiquity/ui/views/tests/test_identity.py | 8 ++++---- .../ui/views/tests/test_installprogress.py | 11 +++++------ subiquity/ui/views/tests/test_welcome.py | 10 +++++----- subiquitycore/testing/__init__.py | 0 .../testing/view_helpers.py | 0 6 files changed, 23 insertions(+), 23 deletions(-) create mode 100644 subiquitycore/testing/__init__.py rename subiquity/ui/views/tests/helpers.py => subiquitycore/testing/view_helpers.py (100%) diff --git a/subiquity/ui/views/filesystem/tests/test_guided.py b/subiquity/ui/views/filesystem/tests/test_guided.py index 34f19927..5306d20d 100644 --- a/subiquity/ui/views/filesystem/tests/test_guided.py +++ b/subiquity/ui/views/filesystem/tests/test_guided.py @@ -3,10 +3,11 @@ from unittest import mock import urwid +from subiquitycore.testing import view_helpers + from subiquity.controllers.filesystem import FilesystemController from subiquity.ui.views.filesystem.guided import GuidedFilesystemView -from subiquity.ui.views.tests import helpers class GuidedFilesystemViewTests(unittest.TestCase): @@ -17,7 +18,7 @@ class GuidedFilesystemViewTests(unittest.TestCase): def test_initial_focus(self): view = self.make_view() - focus_path = helpers.get_focus_path(view) + focus_path = view_helpers.get_focus_path(view) for w in reversed(focus_path): if isinstance(w, urwid.Button) and w.label == "Use An Entire Disk": return @@ -26,18 +27,18 @@ class GuidedFilesystemViewTests(unittest.TestCase): def test_click_guided(self): view = self.make_view() - button = helpers.find_button_matching(view, "^Use An Entire Disk$") - helpers.click(button) + button = view_helpers.find_button_matching(view, "^Use An Entire Disk$") + view_helpers.click(button) view.controller.guided.assert_called_once_with() def test_click_manual(self): view = self.make_view() - button = helpers.find_button_matching(view, "^Manual$") - helpers.click(button) + button = view_helpers.find_button_matching(view, "^Manual$") + view_helpers.click(button) view.controller.manual.assert_called_once_with() def test_click_back(self): view = self.make_view() - button = helpers.find_button_matching(view, "^Back$") - helpers.click(button) + button = view_helpers.find_button_matching(view, "^Back$") + view_helpers.click(button) view.controller.cancel.assert_called_once_with() diff --git a/subiquity/ui/views/tests/test_identity.py b/subiquity/ui/views/tests/test_identity.py index b90eb8f3..cba159f1 100644 --- a/subiquity/ui/views/tests/test_identity.py +++ b/subiquity/ui/views/tests/test_identity.py @@ -3,11 +3,11 @@ from unittest import mock from subiquitycore.models.identity import IdentityModel from subiquitycore.signals import Signal +from subiquitycore.testing import view_helpers from subiquity.controllers.identity import IdentityController from subiquity.ui.views.identity import IdentityView -from subiquity.ui.views.tests import helpers class IdentityViewTests(unittest.TestCase): @@ -27,7 +27,7 @@ class IdentityViewTests(unittest.TestCase): def test_initial_focus(self): view = self.make_view() - focus_path = helpers.get_focus_path(view) + focus_path = view_helpers.get_focus_path(view) for w in reversed(focus_path): if w is view.form.realname.widget: return @@ -39,8 +39,8 @@ class IdentityViewTests(unittest.TestCase): self.enter_valid_data(view) self.assertTrue(view.form.done_btn.enabled) for i in range(10): - helpers.keypress(view, 'tab', size=(80, 24)) - focus_path = helpers.get_focus_path(view) + view_helpers.keypress(view, 'tab', size=(80, 24)) + focus_path = view_helpers.get_focus_path(view) for w in reversed(focus_path): if w is view.form.done_btn: return diff --git a/subiquity/ui/views/tests/test_installprogress.py b/subiquity/ui/views/tests/test_installprogress.py index 27e1ed0d..5c478fba 100644 --- a/subiquity/ui/views/tests/test_installprogress.py +++ b/subiquity/ui/views/tests/test_installprogress.py @@ -1,12 +1,11 @@ import unittest from unittest import mock +from subiquitycore.testing import view_helpers from subiquity.controllers.installprogress import InstallProgressController from subiquity.ui.views.installprogress import ProgressView -from subiquity.ui.views.tests import helpers - class IdentityViewTests(unittest.TestCase): @@ -16,7 +15,7 @@ class IdentityViewTests(unittest.TestCase): def test_initial_focus(self): view = self.make_view() - for w in reversed(helpers.get_focus_path(view)): + for w in reversed(view_helpers.get_focus_path(view)): if w is view.listbox: return else: @@ -24,10 +23,10 @@ class IdentityViewTests(unittest.TestCase): def test_show_complete(self): view = self.make_view() - btn = helpers.find_button_matching(view, "^Reboot Now$") + btn = view_helpers.find_button_matching(view, "^Reboot Now$") self.assertIs(btn, None) view.show_complete() - btn = helpers.find_button_matching(view, "^Reboot Now$") + btn = view_helpers.find_button_matching(view, "^Reboot Now$") self.assertIsNot(btn, None) - helpers.click(btn) + view_helpers.click(btn) view.controller.reboot.assert_called_once_with() diff --git a/subiquity/ui/views/tests/test_welcome.py b/subiquity/ui/views/tests/test_welcome.py index 8f366c66..b46a0f9e 100644 --- a/subiquity/ui/views/tests/test_welcome.py +++ b/subiquity/ui/views/tests/test_welcome.py @@ -3,12 +3,12 @@ from unittest import mock import urwid +from subiquitycore.testing import view_helpers + from subiquity.controllers.welcome import WelcomeController from subiquity.models.locale import LocaleModel from subiquity.ui.views.welcome import WelcomeView -from subiquity.ui.views.tests import helpers - class WelcomeViewTests(unittest.TestCase): @@ -22,8 +22,8 @@ class WelcomeViewTests(unittest.TestCase): # Clicking the button for a language calls "switch_language" # on the model and "done" on the controller. view = self.make_view_with_languages([('code', 'lang', 'native')]) - but = helpers.find_button_matching(view, "^native$") - helpers.click(but) + but = view_helpers.find_button_matching(view, "^native$") + view_helpers.click(but) view.model.switch_language.assert_called_once_with("code") view.controller.done.assert_called_once_with() @@ -34,7 +34,7 @@ class WelcomeViewTests(unittest.TestCase): ('code1', 'lang1', 'native1'), ('code2', 'lang2', 'native2'), ]) - for w in reversed(helpers.get_focus_path(view)): + for w in reversed(view_helpers.get_focus_path(view)): if isinstance(w, urwid.Button): self.assertEqual(w.label, "native1") break diff --git a/subiquitycore/testing/__init__.py b/subiquitycore/testing/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/subiquity/ui/views/tests/helpers.py b/subiquitycore/testing/view_helpers.py similarity index 100% rename from subiquity/ui/views/tests/helpers.py rename to subiquitycore/testing/view_helpers.py