Пример #1
0
    def test_pull_and_build_node_packages_sources(self):
        class Options:
            source = None
            node_packages = ['my-pkg']

        plugin = nodejs.NodePlugin('test-part', Options(),
                                   self.project_options)

        os.makedirs(plugin.sourcedir)

        plugin.pull()
        plugin.build()

        self.run_mock.assert_has_calls([
            mock.call(['npm', 'install', '-g', 'my-pkg'], cwd=plugin.builddir)
        ])
        self.tar_mock.assert_has_calls([
            mock.call(
                nodejs._get_nodejs_release(),
                path.join(os.path.abspath('.'), 'parts', 'test-part', 'npm')),
            mock.call().download(),
            mock.call().provision(plugin.installdir,
                                  clean_target=False,
                                  keep_tarball=True)
        ])
Пример #2
0
    def test_pull_local_sources(self):
        class Options:
            source = '.'
            node_packages = []

        plugin = nodejs.NodePlugin('test-part', Options())

        os.makedirs(plugin.sourcedir)

        plugin.pull()

        self.assertFalse(self.run_mock.called, 'run() was called')
        self.tar_mock.assert_has_calls([
            mock.call(
                nodejs._get_nodejs_release(),
                path.join(os.path.abspath('.'), 'parts', 'test-part', 'npm')),
            mock.call().download()])
Пример #3
0
    def test_pull_local_sources(self):
        class Options:
            source = '.'
            node_packages = []

        plugin = nodejs.NodePlugin('test-part', Options())

        os.makedirs(plugin.sourcedir)

        plugin.pull()

        self.assertFalse(self.run_mock.called, 'run() was called')
        self.tar_mock.assert_has_calls([
            mock.call(
                nodejs._get_nodejs_release(),
                path.join(os.path.abspath('.'), 'parts', 'test-part', 'npm')),
            mock.call().pull()
        ])
Пример #4
0
    def test_build_local_sources(self):
        class Options:
            source = '.'
            node_packages = []

        plugin = nodejs.NodePlugin('test-part', Options())

        os.makedirs(plugin.sourcedir)
        open(os.path.join(plugin.sourcedir, 'package.json'), 'w').close()

        plugin.build()

        self.run_mock.assert_has_calls([
            mock.call(['npm', 'install', '-g'], cwd=plugin.builddir)])
        self.tar_mock.assert_has_calls([
            mock.call(
                nodejs._get_nodejs_release(),
                path.join(os.path.abspath('.'), 'parts', 'test-part', 'npm')),
            mock.call().provision(plugin.installdir)])
Пример #5
0
    def test_build_local_sources(self):
        class Options:
            source = '.'
            node_packages = []

        plugin = nodejs.NodePlugin('test-part', Options())

        os.makedirs(plugin.sourcedir)
        open(os.path.join(plugin.sourcedir, 'package.json'), 'w').close()

        plugin.build()

        self.run_mock.assert_has_calls(
            [mock.call(['npm', 'install', '-g'], cwd=plugin.builddir)])
        self.tar_mock.assert_has_calls([
            mock.call(
                nodejs._get_nodejs_release(),
                path.join(os.path.abspath('.'), 'parts', 'test-part', 'npm')),
            mock.call().provision(plugin.installdir)
        ])
Пример #6
0
    def test_pull_and_build_node_packages_sources(self):
        class Options:
            source = None
            node_packages = ['my-pkg']

        plugin = nodejs.NodePlugin('test-part', Options())

        os.makedirs(plugin.sourcedir)

        plugin.pull()
        plugin.build()

        self.run_mock.assert_has_calls([
            mock.call(['npm', 'install', '-g', 'my-pkg'],
                      cwd=plugin.builddir)])
        self.tar_mock.assert_has_calls([
            mock.call(
                nodejs._get_nodejs_release(),
                path.join(os.path.abspath('.'), 'parts', 'test-part', 'npm')),
            mock.call().download(),
            mock.call().provision(plugin.installdir)])