Ejemplo n.º 1
0
 def setUp(self):
     self.ubi_timezone = plugin_manager.load_plugin('ubi-timezone')
     db = debconf.DebconfCommunicator('ubi-test', cloexec=True)
     self.addCleanup(db.shutdown)
     controller = mock.Mock()
     controller.dbfilter = self.ubi_timezone.Page(None, db=db)
     self.gtk = self.ubi_timezone.PageGtk(controller)
 def setUp(self):
     self.ubi_timezone = plugin_manager.load_plugin('ubi-timezone')
     db = debconf.DebconfCommunicator('ubi-test', cloexec=True)
     self.addCleanup(db.shutdown)
     controller = mock.Mock()
     controller.dbfilter = self.ubi_timezone.Page(None, db=db)
     self.gtk = self.ubi_timezone.PageGtk(controller)
Ejemplo n.º 3
0
 def setUp(self):
     self.ubi_timezone = plugin_manager.load_plugin('ubi-timezone')
     with EnvironmentVarGuard() as env:
         env["LC_ALL"] = "en_US.UTF-8"
         db = debconf.DebconfCommunicator('ubi-test', cloexec=True)
     self.addCleanup(db.shutdown)
     controller = mock.Mock()
     controller.dbfilter = self.ubi_timezone.Page(None, db=db)
     self.gtk = self.ubi_timezone.PageGtk(controller)
Ejemplo n.º 4
0
 def setUp(self):
     self.ubi_timezone = plugin_manager.load_plugin('ubi-timezone')
     with EnvironmentVarGuard() as env:
         env["LC_ALL"] = "en_US.UTF-8"
         db = debconf.DebconfCommunicator('ubi-test', cloexec=True)
     self.addCleanup(db.shutdown)
     controller = mock.Mock()
     controller.dbfilter = self.ubi_timezone.Page(None, db=db)
     self.gtk = self.ubi_timezone.PageGtk(controller)
Ejemplo n.º 5
0
 def setUp(self):
     for obj in ("ubiquity.misc.execute", "ubiquity.misc.execute_root", "ubiquity.misc.dmimodel"):
         patcher = mock.patch(obj)
         patcher.start()
         self.addCleanup(patcher.stop)
     ubi_usersetup = plugin_manager.load_plugin("ubi-usersetup")
     controller = mock.Mock()
     controller.oem_config = False
     self.ubi_usersetup = ubi_usersetup
     self.gtk = self.ubi_usersetup.PageGtk(controller)
Ejemplo n.º 6
0
 def setUp(self):
     for obj in ('ubiquity.misc.execute', 'ubiquity.misc.execute_root',
                 'ubiquity.misc.dmimodel'):
         patcher = mock.patch(obj)
         patcher.start()
         self.addCleanup(patcher.stop)
     ubi_usersetup = plugin_manager.load_plugin('ubi-usersetup')
     controller = mock.Mock()
     controller.oem_config = False
     self.ubi_usersetup = ubi_usersetup
     self.gtk = self.ubi_usersetup.PageGtk(controller)
Ejemplo n.º 7
0
    def setUp(self, has_connection, get_state, *args):
        has_connection.return_value = True
        get_state.return_value = nm.NM_STATE_DISCONNECTED

        self.ubi_wireless = plugin_manager.load_plugin('ubi-wireless')

        self.gtk = self.ubi_wireless.PageGtk(mock.Mock())
        self.nmwidget = self.gtk.nmwidget
        self.manager = self.nmwidget.view.wifi_model
        self.model = self.manager.model
        self.manager.passphrases_cache = {}
    def setUp(self, has_connection, get_state, *args):
        has_connection.return_value = True
        get_state.return_value = nm.NM_STATE_DISCONNECTED

        self.ubi_wireless = plugin_manager.load_plugin('ubi-wireless')

        self.gtk = self.ubi_wireless.PageGtk(mock.Mock())
        self.nmwidget = self.gtk.nmwidget
        self.manager = self.nmwidget.view.wifi_model
        self.model = self.manager.model
        self.manager.passphrases_cache = {}
Ejemplo n.º 9
0
    def setUp(self):
        for obj in ('ubiquity.misc.execute', 'ubiquity.misc.execute_root'):
            patcher = mock.patch(obj)
            patcher.start()
            self.addCleanup(patcher.stop)

        ubi_language = plugin_manager.load_plugin('ubi-language')

        controller = mock.Mock()
        controller.oem_user_config = True
        controller.oem_config = False
        self.ubi_language = ubi_language
        self.gtk = self.ubi_language.PageGtk(controller)
Ejemplo n.º 10
0
    def setUp(self):
        for obj in ('ubiquity.misc.execute', 'ubiquity.misc.execute_root'):
            patcher = mock.patch(obj)
            patcher.start()
            self.addCleanup(patcher.stop)

        ubi_language = plugin_manager.load_plugin('ubi-language')

        controller = mock.Mock()
        controller.oem_user_config = True
        controller.oem_config = False
        self.ubi_language = ubi_language
        self.gtk = self.ubi_language.PageGtk(controller)
Ejemplo n.º 11
0
    def setUp(self):
        for obj in ('ubiquity.misc.execute', 'ubiquity.misc.execute_root'):
            patcher = mock.patch(obj)
            patcher.start()
            self.addCleanup(patcher.stop)

        ubi_language = plugin_manager.load_plugin('ubi-language')

        self.controller = mock.Mock()
        self.controller.oem_user_config = False
        self.controller.oem_config = False
        self.ubi_language = ubi_language
        # Set the environment variable needed in order for PageGtk to hook up
        # the Try Xenta OS button with the appropriate action.
        with EnvironmentVarGuard() as environ:
            environ['UBIQUITY_GREETER'] = '1'
            self.gtk = self.ubi_language.PageGtk(self.controller)
Ejemplo n.º 12
0
    def setUp(self):
        for obj in ('ubiquity.misc.execute', 'ubiquity.misc.execute_root'):
            patcher = mock.patch(obj)
            patcher.start()
            self.addCleanup(patcher.stop)

        ubi_language = plugin_manager.load_plugin('ubi-language')

        self.controller = mock.Mock()
        self.controller.oem_user_config = False
        self.controller.oem_config = False
        self.ubi_language = ubi_language
        # Set the environment variable needed in order for PageGtk to hook up
        # the Try Linux Mint button with the appropriate action.
        with EnvironmentVarGuard() as environ:
            environ['UBIQUITY_GREETER'] = '1'
            self.gtk = self.ubi_language.PageGtk(self.controller)
Ejemplo n.º 13
0
#!/usr/bin/python3

import os
import unittest
import unittest.mock
from test.support import run_unittest

import debconf

from ubiquity import plugin_manager

ubi_console_setup = plugin_manager.load_plugin("ubi-console-setup")


@unittest.skipUnless("DEBCONF_SYSTEMRC" in os.environ, "Need a database.")
class TestPageBase(unittest.TestCase):
    def setUp(self):
        # We could mock out the db for this, but we ultimately want to make
        # sure that the debconf questions it's getting exist.
        self.page = ubi_console_setup.Page(None, ui=unittest.mock.Mock())
        self.page.db = debconf.DebconfCommunicator("ubi-test", cloexec=True)
        self.addCleanup(self.page.db.shutdown)


class TestPage(TestPageBase):
    DEFAULT_ENGLISH_KEYBOARDS = [
        ("xkb", "us"),
        ("xkb", "au"),
        ("xkb", "cm"),
        ("xkb", "gb"),
    ]
Ejemplo n.º 14
0
#!/usr/bin/python3

from itertools import zip_longest
import os
from test.support import run_unittest
import unittest

import debconf
# These tests require Mock 0.7.0
import mock

from ubiquity import misc, plugin_manager


ubi_partman = plugin_manager.load_plugin('ubi-partman')


def question_has_variables(question, lookup_variables):
    existing_variables = []
    found_question = False
    if 'UBIQUITY_TEST_INSTALLED' in os.environ:
        templates_dat = '/var/cache/debconf/templates.dat'
    else:
        templates_dat = 'tests/templates.dat'
    # Templates files are (at least in theory) mixed-encoding, so we must
    # treat them as binary data and decode only marked elements.  In this
    # function, we only care about question and variable names, which should
    # always be ASCII.
    with open(templates_dat, 'rb') as templates:
        for line in templates:
            if found_question and line == b'\n':
Ejemplo n.º 15
0
    def _on_button_next_clicked(button):
        stop = page_gtk.plugin_on_next_clicked()
        if not stop:
            Gtk.main_quit()

    # setup env
    for envvar, path in (
            ("UBIQUITY_PLUGIN_PATH", "./ubiquity/plugins"),
            ("UBIQUITY_GLADE", "./gui/gtk")):
        if os.path.exists(path):
            os.environ[envvar] = path
    # ... and then import the plugin_manager
    from ubiquity.plugin_manager import load_plugin

    plugin_name = sys.argv[1]
    plugin_module = load_plugin(plugin_name)

    win = Gtk.Window()
    win.button_next = Gtk.Button("next")
    win.button_back = Gtk.Button("back")

    mock_controller = MockController(win)
    page_gtk = plugin_module.PageGtk(mock_controller)
    page_gtk.plugin_translate("en")

    # this user password is for the Ubuntu SSO plugin, to test keyring
    # creation.
    page_gtk._user_password = "******"

    win.button_next.connect(
        "clicked", _on_button_next_clicked)
Ejemplo n.º 16
0
#!/usr/bin/python3

import http.client
import json
import oauthlib
import unittest

from mock import call, DEFAULT, Mock, patch, PropertyMock, sentinel
from gi.repository import Gtk

from ubiquity import plugin_manager


ubi_ubuntuone = plugin_manager.load_plugin('ubi-ubuntuone')


class TokenNameTestCase(unittest.TestCase):

    def test_simple_token_name(self):
        name = ubi_ubuntuone.get_token_name('simple')
        self.assertEqual(name, "Ubuntu One @ simple")

    def test_complex_token_name(self):
        name = ubi_ubuntuone.get_token_name('simple @ complex')
        self.assertEqual(name, "Ubuntu One @ simple AT complex")


class BaseTestPageGtk(unittest.TestCase):

    def setUp(self):
        mock_controller = Mock()
Ejemplo n.º 17
0
#!/usr/bin/python3

from itertools import zip_longest
import os
from test.support import run_unittest
import unittest

import debconf
# These tests require Mock 0.7.0
import mock

from ubiquity import misc, plugin_manager

ubi_partman = plugin_manager.load_plugin('ubi-partman')


def question_has_variables(question, lookup_variables):
    existing_variables = []
    found_question = False
    if 'UBIQUITY_TEST_INSTALLED' in os.environ:
        templates_dat = '/var/cache/debconf/templates.dat'
    else:
        templates_dat = 'tests/templates.dat'
    # Templates files are (at least in theory) mixed-encoding, so we must
    # treat them as binary data and decode only marked elements.  In this
    # function, we only care about question and variable names, which should
    # always be ASCII.
    with open(templates_dat, 'rb') as templates:
        for line in templates:
            if found_question and line == b'\n':
                break
    def _on_button_next_clicked(button):
        stop = page_gtk.plugin_on_next_clicked()
        if not stop:
            Gtk.main_quit()

    # setup env
    for envvar, path in (
            ("UBIQUITY_PLUGIN_PATH", "./ubiquity/plugins"),
            ("UBIQUITY_GLADE", "./gui/gtk")):
        if os.path.exists(path):
            os.environ[envvar] = path
    # ... and then import the plugin_manager
    from ubiquity.plugin_manager import load_plugin

    plugin_name = sys.argv[1]
    plugin_module = load_plugin(plugin_name)

    win = Gtk.Window()
    win.button_next = Gtk.Button("next")
    win.button_back = Gtk.Button("back")

    mock_controller = MockController(win)
    page_gtk = plugin_module.PageGtk(mock_controller)
    page_gtk.plugin_translate("en")

    win.button_next.connect(
        "clicked", _on_button_next_clicked)
    win.button_back.connect(
        "clicked", lambda b: page_gtk.plugin_on_back_clicked())

    add_connection_watch(page_gtk.plugin_set_online_state)