# Path: dukpy/install.py
# def main():
# def install_jspackage(package_name, version, modulesdir):
# def _resolve_version(version, versions):
# def _fetch_package_info(package_name):
# def _resolve_dependencies(package_name, version):
#     def __init__(self, msg, error_code):
# class JSPackageInstallError(Exception):


import os
import shutil
import tempfile
import unittest
import sys
import mock
import dukpy
from dukpy import install as dukpy_install
        jsi.loader.register_path(self.tmpdir)
        res = jsi.evaljs(jsx, data={'id': 1, 'name': "Alessandro"})
        assert res == '<div class="helloworld">Hello Alessandro</div>', res

    def test_install_command(self):
        with mock.patch.object(sys, 'argv', ['dukpy-install', 'react', '0.14.8',
                                             '-d', self.tmpdir]):
            dukpy_install.main()
        assert os.path.exists(os.path.join(self.tmpdir, 'react'))

    def test_install_command_latest_ver(self):
        with mock.patch.object(sys, 'argv', ['dukpy-install', 'react', '-d', self.tmpdir]):
            dukpy_install.main()
        assert os.path.exists(os.path.join(self.tmpdir, 'react'))

    def test_install_command_missing_args(self):
        with self.assertRaises(SystemExit):
            with mock.patch.object(sys, 'argv', ['dukpy-install']):
                dukpy_install.main()

    def test_install_command_without_dest(self):
        if os.path.exists('./js_modules'):
            self.skipTest('local destination directory already exists...')

        with mock.patch.object(sys, 'argv', ['dukpy-install', 'react', '0.14.8']):
            dukpy_install.main()
        assert os.path.exists(os.path.join('./js_modules', 'react'))

    def test_install_scoped_package(self):
        with mock.patch.object(sys, 'argv', ['dukpy-install', '@reactivex/rxjs', '5.0.0-beta.11']):

# Path: dukpy/install.py
# def main():
# def install_jspackage(package_name, version, modulesdir):
# def _resolve_version(version, versions):
# def _fetch_package_info(package_name):
# def _resolve_dependencies(package_name, version):
#     def __init__(self, msg, error_code):
# class JSPackageInstallError(Exception):


# Path: tests/test_installer.py
import os
import shutil
import tempfile
import unittest
import sys
import mock
import dukpy
from dukpy import install as dukpy_install

        jsi.loader.register_path(self.tmpdir)
        res = jsi.evaljs(jsx, data={'id': 1, 'name': "Alessandro"})
        assert res == '<div class="helloworld">Hello Alessandro</div>', res

    def test_install_command(self):
        with mock.patch.object(sys, 'argv', ['dukpy-install', 'react', '0.14.8',
                                             '-d', self.tmpdir]):
            dukpy_install.main()
        assert os.path.exists(os.path.join(self.tmpdir, 'react'))

    def test_install_command_latest_ver(self):
        with mock.patch.object(sys, 'argv', ['dukpy-install', 'react', '-d', self.tmpdir]):
            dukpy_install.main()
        assert os.path.exists(os.path.join(self.tmpdir, 'react'))

    def test_install_command_missing_args(self):
        with self.assertRaises(SystemExit):
            with mock.patch.object(sys, 'argv', ['dukpy-install']):
                dukpy_install.main()

    def test_install_command_without_dest(self):
        if os.path.exists('./js_modules'):
            self.skipTest('local destination directory already exists...')

        with mock.patch.object(sys, 'argv', ['dukpy-install', 'react', '0.14.8']):
            dukpy_install.main()
        assert os.path.exists(os.path.join('./js_modules', 'react'))

    def test_install_scoped_package(self):
        with mock.patch.object(sys, 'argv', ['dukpy-install', '@reactivex/rxjs', '5.0.0-beta.11']):

            dukpy_install.main()