move subiquity.ui.views.tests.helpers to subiquitycore.testing.view_helpers
This commit is contained in:
parent
c04927eca6
commit
956342478a
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue