Exemple #1
0
    def setUp(self):
        super().setUp()
        temp_cwd_fixture = fixture_setup.TempCWD()
        self.useFixture(temp_cwd_fixture)
        self.path = temp_cwd_fixture.path
        # Some tests will directly or indirectly change the plugindir, which
        # is a module variable. Make sure that it is returned to the original
        # value when a test ends.
        self.addCleanup(common.set_plugindir, common.get_plugindir())
        self.addCleanup(common.set_schemadir, common.get_schemadir())
        self.addCleanup(common.set_schemadir, common.get_schemadir())
        self.addCleanup(common.reset_env)
        common.set_schemadir(os.path.join(__file__,
                             '..', '..', '..', 'schema'))
        self.useFixture(fixtures.FakeLogger(level=logging.ERROR))

        patcher = mock.patch('multiprocessing.cpu_count')
        self.cpu_count = patcher.start()
        self.cpu_count.return_value = 2
        self.addCleanup(patcher.stop)

        # These are what we expect by default
        self.snap_dir = os.path.join(os.getcwd(), 'snap')
        self.stage_dir = os.path.join(os.getcwd(), 'stage')
        self.parts_dir = os.path.join(os.getcwd(), 'parts')
        self.local_plugins_dir = os.path.join(self.parts_dir, 'plugins')
Exemple #2
0
    def test_schema_not_found(self, plugin_mock, local_load_mock):
        mock_plugin = Mock()
        mock_plugin.schema.return_value = {}
        plugin_mock.return_value = mock_plugin
        local_load_mock.return_value = "not None"

        common.set_schemadir(os.path.join('', 'foo'))

        with self.assertRaises(FileNotFoundError):
            pluginhandler.PluginHandler('mock', 'mock-part', {})
    def test_schema_not_found(self, plugin_mock, local_load_mock):
        mock_plugin = Mock()
        mock_plugin.schema.return_value = {}
        plugin_mock.return_value = mock_plugin
        local_load_mock.return_value = "not None"

        common.set_schemadir(os.path.join('', 'foo'))

        with self.assertRaises(FileNotFoundError):
            pluginhandler.PluginHandler('mock', 'mock-part', {})
    def test_schema_not_found(self, plugin_mock, local_load_mock):
        mock_plugin = Mock()
        mock_plugin.schema.return_value = {}
        plugin_mock.return_value = mock_plugin
        local_load_mock.return_value = "not None"

        common.set_schemadir(os.path.join("", "foo"))

        with self.assertRaises(FileNotFoundError):
            snapcraft.lifecycle.PluginHandler("mock", "mock-part", {})
Exemple #5
0
def setup_dirs():
    """
    Ensure that snapcraft.common plugindir is setup correctly
    and support running out of a development snapshot
    """
    from snapcraft import common
    topdir = os.path.abspath(os.path.join(__file__, '..', '..'))
    # only change the default if we are running from a checkout
    if os.path.exists(os.path.join(topdir, 'setup.py')):
        common.set_plugindir(os.path.join(topdir, 'plugins'))
        common.set_schemadir(os.path.join(topdir, 'schema'))
Exemple #6
0
 def setUp(self):
     super().setUp()
     temp_cwd_fixture = fixture_setup.TempCWD()
     self.useFixture(temp_cwd_fixture)
     self.path = temp_cwd_fixture.path
     # Some tests will directly or indirectly change the plugindir, which
     # is a module variable. Make sure that it is returned to the original
     # value when a test ends.
     self.addCleanup(common.set_plugindir, common.get_plugindir())
     self.addCleanup(common.set_schemadir, common.get_schemadir())
     self.addCleanup(common.set_schemadir, common.get_schemadir())
     self.addCleanup(common.reset_env)
     common.set_schemadir(os.path.join(__file__,
                          '..', '..', '..', 'schema'))
Exemple #7
0
 def setUp(self):
     super().setUp()
     temp_cwd_fixture = fixture_setup.TempCWD()
     self.useFixture(temp_cwd_fixture)
     self.path = temp_cwd_fixture.path
     # Some tests will directly or indirectly change the plugindir, which
     # is a module variable. Make sure that it is returned to the original
     # value when a test ends.
     self.addCleanup(common.set_plugindir, common.get_plugindir())
     self.addCleanup(common.set_schemadir, common.get_schemadir())
     self.addCleanup(common.set_schemadir, common.get_schemadir())
     self.addCleanup(common.reset_env)
     common.set_schemadir(os.path.join(__file__,
                          '..', '..', '..', 'schema'))
 def setUp(self):
     super().setUp()
     common.set_schemadir(os.path.join(__file__, "..", "..", "..", "schema"))
Exemple #9
0
 def setUp(self):
     super().setUp()
     common.set_schemadir(os.path.join(__file__,
                          '..', '..', '..', 'schema'))
Exemple #10
0
 def setUp(self):
     super().setUp()
     common.set_schemadir(os.path.join(__file__, '..', '..', '..',
                                       'schema'))