def test_install_unexisting_package(self): try: dukpy.install_jspackage('non_existing_suerly_missing_dunno', '1', self.tmpdir) except: pass else: assert False, 'Should have not found exception'
def test_install_missing_download_url(self): with mock.patch('dukpy.install._fetch_package_info', new=lambda *args: {'versions': {'99.9.9': {}}}): try: dukpy.install_jspackage('react', '99.9.9', self.tmpdir) except Exception as e: assert 'Unable to detect a supported download url' in str(e), str(e) raise
def test_install_missing_download_url(self): with mock.patch('dukpy.install._fetch_package_info', new=lambda *args: {'versions': { '99.9.9': {} }}): with self.assertRaises(dukpy_install.JSPackageInstallError) as err: dukpy.install_jspackage('react', '99.9.9', self.tmpdir) assert 'Unable to detect a supported download url' in str( err.exception)
def test_install_react(self): dukpy.install_jspackage('react', '0.14.8', self.tmpdir) dukpy.install_jspackage('react-dom', '0.14.8', self.tmpdir) jsx = dukpy.jsx_compile(TEST_CODE) jsi = dukpy.JSInterpreter() 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_missing_download_url(self): with mock.patch('dukpy.install._fetch_package_info', new=lambda *args: {'versions': { '99.9.9': {} }}): try: dukpy.install_jspackage('react', '99.9.9', self.tmpdir) except Exception as e: assert 'Unable to detect a supported download url' in str( e), str(e) raise
def test_install_unexisting_version(self): dukpy.install_jspackage('react', '9999', self.tmpdir)
def test_install_unexisting_version(self): with self.assertRaises(dukpy_install.JSPackageInstallError): dukpy.install_jspackage('react', '9999', self.tmpdir)
def test_install_unexisting_package(self): with self.assertRaises(Exception) as err: dukpy.install_jspackage('non_existing_suerly_missing_dunno', '1', self.tmpdir) assert 'Not Found' in str(err.exception)