예제 #1
0
 def test_current_ui_first(self, cv, ccsv):
     app = make_app(model=make_model())
     c = RecoveryChooserController(app)
     # current system view is constructed
     ccsv.assert_called_with(c, c.model.current, has_more=True)
     # as well as all systems view
     cv.assert_called_with(c, c.model.systems)
     v = c.make_ui()
     self.assertEqual(v, 'current')
     # user selects more options and the view is replaced
     c.more_options()
     c.ui.set_body.assert_called_with('all')
예제 #2
0
    def test_select(self):
        app = make_app(model=make_model())
        c = RecoveryChooserController(app)

        c.select(c.model.systems[0], c.model.systems[0].actions[0])
        exp = SelectedSystemAction(system=c.model.systems[0],
                                   action=c.model.systems[0].actions[0])
        self.assertEqual(c.model.selection, exp)

        app.next_screen.assert_called()
        app.respond.assert_not_called()
        app.exit.assert_not_called()
예제 #3
0
    def test_only_one_and_current(self, cv, ccsv):
        model = RecoverySystemsModel.from_systems([model2_current])
        app = make_app(model=model)
        c = RecoveryChooserController(app)
        # both views are constructed
        ccsv.assert_called_with(c, c.model.current, has_more=False)
        cv.assert_called_with(c, c.model.systems)

        v = c.make_ui()
        self.assertEqual(v, 'current')
        # going back does nothing
        c.back()
        c.ui.set_body.not_called()
예제 #4
0
    def test_all_systems_first_no_current(self, cv, ccsv):
        model = RecoverySystemsModel.from_systems([model1_non_current])
        app = make_app(model=model)
        c = RecoveryChooserController(app)

        # sanity
        self.assertIsNone(c.model.current)

        # we get the all-systems view now
        cv.assert_called()
        # current system view is not constructed at all
        ccsv.assert_not_called()

        v = c.make_ui()
        self.assertEqual(v, 'all')
예제 #5
0
    def test_all_systems_first_no_current(self, cv, ccsv):
        model = RecoverySystemsModel.from_systems([model1_non_current])
        app = make_app(model=model)
        c = RecoveryChooserController(app)
        c.ui.start_ui = mock.Mock()

        # sanity
        self.assertIsNone(c.model.current)

        # we get the all-systems view now
        cv.assert_called()
        # current system view is not constructed at all
        ccsv.assert_not_called()

        c.start_ui()
        c.ui.set_body.assert_called_with('all')
예제 #6
0
    def test_current_current_all_there_and_back(self, cv, ccsv):
        app = make_app(model=make_model())
        c = RecoveryChooserController(app)
        c.ui.start_ui = mock.Mock()
        # sanity
        ccsv.assert_called_with(c, c.model.current, has_more=True)
        cv.assert_called_with(c, c.model.systems)

        c.start_ui()
        c.ui.set_body.assert_called_with('current')
        # user selects more options and the view is replaced
        c.more_options()
        c.ui.set_body.assert_called_with('all')
        # go back now
        c.back()
        c.ui.set_body.assert_called_with('current')
        # nothing
        c.back()
        c.ui.set_body.not_called()