Esempio n. 1
0
 def test_npm_version_get(self):
     version = npm.get_npm_version()
     self.assertTrue(isinstance(version, tuple))
     self.assertGreater(len(version), 0)
Esempio n. 2
0
            rjs.modname_source_target_to_modpath(spec, modname, source, ''),
            'module',
        )

    def test_modname_source_target_to_modpath_empty(self):
        modname = 'module'
        source = 'empty:'
        rjs = toolchain.RJSToolchain()
        spec = Spec()
        self.assertEqual(
            rjs.modname_source_target_to_modpath(spec, modname, source, ''),
            'empty:',
        )


@unittest.skipIf(get_npm_version() is None, "npm is unavailable")
class ToolchainUnitTestCase(unittest.TestCase):
    """
    Just testing out the toolchain units.
    """
    def test_prepare_failure_manual(self):
        rjs = toolchain.RJSToolchain()
        spec = Spec(rjs_bin='/no/such/path')
        with self.assertRaises(RuntimeError) as e:
            rjs.prepare(spec)

        self.assertEqual(
            str(e.exception),
            "'/no/such/path' does not exist; cannot be used as '%s' binary" %
            (rjs.rjs_bin),
        )
Esempio n. 3
0
def skip_full_toolchain_test():  # pragma: no cover
    if get_npm_version() is None:
        return (True, 'npm not available')
    if os.environ.get('SKIP_FULL'):
        return (True, 'skipping due to SKIP_FULL environment variable')
    return (False, '')
Esempio n. 4
0
 def test_npm_no_path(self):
     os.environ['PATH'] = ''
     with pretty_logging(stream=StringIO()) as stderr:
         self.assertIsNone(npm.get_npm_version())
         self.assertIn("failed to execute 'npm'", stderr.getvalue())
Esempio n. 5
0
            rjs.modname_source_target_to_modpath(spec, modname, source, ''),
            'module',
        )

    def test_modname_source_target_to_modpath_empty(self):
        modname = 'module'
        source = 'empty:'
        rjs = toolchain.RJSToolchain()
        spec = Spec()
        self.assertEqual(
            rjs.modname_source_target_to_modpath(spec, modname, source, ''),
            'empty:',
        )


@unittest.skipIf(get_npm_version() is None, "npm is unavailable")
class ToolchainUnitTestCase(unittest.TestCase):
    """
    Just testing out the toolchain units.
    """

    def test_prepare_failure_manual(self):
        rjs = toolchain.RJSToolchain()
        spec = Spec(toolchain_bin_path='/no/such/path')
        with self.assertRaises(RuntimeError) as e:
            rjs.prepare(spec)

        self.assertEqual(
            str(e.exception),
            "'/no/such/path' does not exist; cannot be used as '%s' binary" % (
                rjs.rjs_bin
Esempio n. 6
0
def skip_full_toolchain_test():  # pragma: no cover
    if get_npm_version() is None:
        return (True, 'npm not available')
    if os.environ.get('SKIP_FULL'):
        return (True, 'skipping due to SKIP_FULL environment variable')
    return (False, '')
Esempio n. 7
0
 def test_npm_version_get(self):
     version = npm.get_npm_version()
     self.assertTrue(isinstance(version, tuple))
     self.assertGreater(len(version), 0)
Esempio n. 8
0
 def test_npm_no_path(self):
     os.environ['PATH'] = ''
     with pretty_logging(stream=StringIO()) as stderr:
         self.assertIsNone(npm.get_npm_version())
         self.assertIn("failed to execute 'npm'", stderr.getvalue())
Esempio n. 9
0
from calmjs.dev.runtime import KarmaRuntime
from calmjs.dev.runtime import TestToolchainRuntime
from calmjs.dev.runtime import KarmaArtifactRuntime

from calmjs.testing import mocks
from calmjs.testing.utils import make_dummy_dist
from calmjs.testing.utils import mkdtemp
from calmjs.testing.utils import remember_cwd
from calmjs.testing.utils import rmtree
from calmjs.testing.utils import setup_class_install_environment
from calmjs.testing.utils import stub_base_which
from calmjs.testing.utils import stub_item_attr_value
from calmjs.testing.utils import stub_mod_call
from calmjs.testing.utils import stub_stdouts

npm_version = get_npm_version()
node_version = get_node_version()


class TestCommonArgparser(unittest.TestCase):
    """
    Test out some non-trivial parsing options in the common parser
    """

    def setUp(self):
        self.parser = ArgumentParser()
        init_argparser_common(self.parser)

    def parse(self, args):
        return self.parser.parse_known_args(args)[0]