class RegisterScreenTests(unittest.TestCase):
    def setUp(self):
        self.backend = StubBackend()
        self.consumer = Mock()
        expected_facts = {
            'fact1': 'one',
            'fact2': 'two',
            'system': '',
            'system.uuid': 'MOCKUUID'
        }
        self.facts = StubFacts(fact_dict=expected_facts)

        self.rs = RegisterScreen(self.backend, self.consumer, self.facts)

    def test_show(self):
        self.rs.show()

    def test_register(self):
        self.rs.uname.set_text("foo")
        self.rs.passwd.set_text("bar")
        self.rs.register()

    def test_show_registration_returns_to_choose_server_screen(self):
        self.rs._server_selected()
        self.rs.uname.set_text("foo")
        self.rs.passwd.set_text("bar")
        self.rs.register()
        self.assertNotEquals(CREDENTIALS_PAGE,
                             self.rs.register_notebook.get_current_page())
        self.rs.cancel(self.rs.cancel_button)
        self.assertNotEquals(CREDENTIALS_PAGE,
                             self.rs.register_notebook.get_current_page())
        self.rs.show()
        self.assertEquals(CHOOSE_SERVER_PAGE,
                          self.rs.register_notebook.get_current_page())

    def test_clear_credentials_dialog(self):
        # Pull initial value here since it will be different per machine.
        default_consumer_name_value = self.rs.consumer_name.get_text()
        self.rs.uname.set_text("foo")
        self.rs.passwd.set_text("bar")
        self.rs.skip_auto_bind.set_active(True)
        self.rs.consumer_name.set_text("CONSUMER")
        self.rs._clear_registration_widgets()
        self.assertEquals("", self.rs.uname.get_text())
        self.assertEquals("", self.rs.passwd.get_text())
        self.assertFalse(self.rs.skip_auto_bind.get_active())
        self.assertEquals(default_consumer_name_value,
                          self.rs.consumer_name.get_text())
class RegisterScreenTests(unittest.TestCase):
    def setUp(self):
        self.backend = StubBackend()
        self.consumer = Mock()
        expected_facts = {'fact1': 'one',
                          'fact2': 'two',
                          'system': '',
                          'system.uuid': 'MOCKUUID'}
        self.facts = StubFacts(fact_dict=expected_facts)

        self.rs = RegisterScreen(self.backend, self.consumer, self.facts)

    def test_show(self):
        self.rs.show()

    def test_register(self):
        self.rs.uname.set_text("foo")
        self.rs.passwd.set_text("bar")
        self.rs.register()

    def test_show_registration_returns_to_choose_server_screen(self):
        self.rs._server_selected()
        self.rs.uname.set_text("foo")
        self.rs.passwd.set_text("bar")
        self.rs.register()
        self.assertNotEquals(CREDENTIALS_PAGE, self.rs.register_notebook.get_current_page())
        self.rs.cancel(self.rs.cancel_button)
        self.assertNotEquals(CREDENTIALS_PAGE, self.rs.register_notebook.get_current_page())
        self.rs.show()
        self.assertEquals(CHOOSE_SERVER_PAGE, self.rs.register_notebook.get_current_page())

    def test_clear_credentials_dialog(self):
        # Pull initial value here since it will be different per machine.
        default_consumer_name_value = self.rs.consumer_name.get_text()
        self.rs.uname.set_text("foo")
        self.rs.passwd.set_text("bar")
        self.rs.skip_auto_bind.set_active(True)
        self.rs.consumer_name.set_text("CONSUMER")
        self.rs._clear_registration_widgets()
        self.assertEquals("", self.rs.uname.get_text())
        self.assertEquals("", self.rs.passwd.get_text())
        self.assertFalse(self.rs.skip_auto_bind.get_active())
        self.assertEquals(default_consumer_name_value, self.rs.consumer_name.get_text())
Exemplo n.º 3
0
class RegisterScreenTests(SubManFixture):
    def setUp(self):
        super(RegisterScreenTests, self).setUp()
        self.backend = StubBackend()
        expected_facts = {
            'fact1': 'one',
            'fact2': 'two',
            'system': '',
            'system.uuid': 'MOCKUUID'
        }
        self.facts = StubFacts(fact_dict=expected_facts)

        self.rs = RegisterScreen(self.backend, self.facts)

        self.rs._screens[CHOOSE_SERVER_PAGE] = Mock()
        self.rs._screens[CHOOSE_SERVER_PAGE].index = 0
        self.rs._screens[CHOOSE_SERVER_PAGE].button_label = "Dummy"
        self.rs._screens[CHOOSE_SERVER_PAGE].apply.return_value = \
                CREDENTIALS_PAGE

    def test_show(self):
        self.rs.show()

    def test_show_registration_returns_to_choose_server_screen(self):
        self.rs.show()
        self.rs.register()
        self.assertEquals(CREDENTIALS_PAGE,
                          self.rs.register_notebook.get_current_page() - 1)
        self.rs.cancel(self.rs.cancel_button)
        self.rs.show()
        self.assertEquals(CHOOSE_SERVER_PAGE,
                          self.rs.register_notebook.get_current_page())
class RegisterScreenTests(SubManFixture):
    def setUp(self):
        super(RegisterScreenTests, self).setUp()
        self.backend = StubBackend()
        expected_facts = {'fact1': 'one',
                          'fact2': 'two',
                          'system': '',
                          'system.uuid': 'MOCKUUID'}
        self.facts = StubFacts(fact_dict=expected_facts)

        self.rs = RegisterScreen(self.backend, self.facts)

        self.rs._screens[CHOOSE_SERVER_PAGE] = Mock()
        self.rs._screens[CHOOSE_SERVER_PAGE].index = 0
        self.rs._screens[CHOOSE_SERVER_PAGE].button_label = "Dummy"
        self.rs._screens[CHOOSE_SERVER_PAGE].apply.return_value = \
                CREDENTIALS_PAGE

    def test_show(self):
        self.rs.show()

    def test_show_registration_returns_to_choose_server_screen(self):
        self.rs.show()
        self.rs.register()
        self.assertEquals(CREDENTIALS_PAGE,
                          self.rs.register_notebook.get_current_page() - 1)
        self.rs.cancel(self.rs.cancel_button)
        self.rs.show()
        self.assertEquals(CHOOSE_SERVER_PAGE,
                          self.rs.register_notebook.get_current_page())