def test_normalize_declaration_package_and_index(self): cut = NodeDeclaration("fran/noderedis") block_cell_names = [ BlockCellName("fran/noderedis/index.js"), BlockCellName("fran/noderedis/package.json") ] self.assertEquals(cut, cut.normalize(block_cell_names))
def test_same_path_relative_index_require(self): cut = NodeDeclaration("./") origin_block_cell_name = BlockCellName("fran/noderedis/bench.js") block_cell_names = [ BlockCellName("fran/noderedis/index.js"), BlockCellName("fran/noderedis/client.js") ] m = cut.match(block_cell_names, origin_block_cell_name) self.assertItemsEqual(set(["fran/noderedis/index.js"]), m)
def test_match_with_implicit_require(self): cut = NodeDeclaration("fran/noderedis") block_cell_names = [ BlockCellName("fran/noderedis/index.js"), BlockCellName("fran/noderedis/other.js") ] self.assertItemsEqual(set([BlockCellName("fran/noderedis/index.js")]), cut.match(block_cell_names))
def test_package_json_recognition(self): cut = NodeDeclaration("fran/noderedis") block_cell_names = [ BlockCellName("fran/noderedis/package.json"), BlockCellName("fran/noderedis/other.js") ] self.assertItemsEqual( set([BlockCellName("fran/noderedis/package.json")]), cut.match(block_cell_names))
def test_one_level_relative_require_with_depth(self): cut = NodeDeclaration("./lib/parser/queue") origin_block_cell_name = BlockCellName("fran/noderedis/index.js") block_cell_names = [ BlockCellName("fran/noderedis/index.js"), BlockCellName("fran/noderedis/lib/queue.js"), BlockCellName("fran/noderedis/lib/parser/queue.js") ] self.assertItemsEqual( set(["fran/noderedis/lib/parser/queue.js"]), cut.match(block_cell_names, origin_block_cell_name))
def test_relative_require_not_found(self): cut = NodeDeclaration("../parser") origin_block_cell_name = BlockCellName( "fran/noderedis/other/thing/other.js") block_cell_names = [ BlockCellName("fran/noderedis/index.js"), BlockCellName("fran/noderedis/other/thing/other.js"), BlockCellName("fran/noderedis/parser.js") ] self.assertItemsEqual( set(), cut.match(block_cell_names, origin_block_cell_name))
def explicit_declarations(self): result = set() result |= (set([NodeDeclaration(x.name) for x in self.requires])) result |= (set([DataDeclaration(x.name) for x in self.references])) return result
def simple_dependencies_node_test(self): block_holder = self._cells_setup('dummy/geom', ['spherefun.js', 'sphere.js', 'main.js', 'other.js'], JS) # Parse processor setup block_holder['main.js'].cell.dependencies.unresolved = {NodeDeclaration('http.js'), NodeDeclaration('./sphere.js'), NodeDeclaration('other.js')} block_holder['sphere.js'].cell.dependencies.unresolved = {NodeDeclaration('http.js'), NodeDeclaration('url.js'), NodeDeclaration('./spherefun.js')} process_holder(block_holder, DependenciesProcessor()) # Checks mainR = block_holder['main.js'].cell self.assertEqual(mainR.dependencies.explicit, {'dummy/geom/sphere.js'}) self.assertEqual(mainR.dependencies.system, {'http.js'}) self.assertEqual(mainR.dependencies.resolved, {NodeDeclaration('http.js'), NodeDeclaration('./sphere.js')}) self.assertEqual(mainR.dependencies.unresolved, {NodeDeclaration('other.js')}) sphereR = block_holder['sphere.js'].cell self.assertEqual(sphereR.dependencies.explicit, {'dummy/geom/spherefun.js'}) self.assertEqual(sphereR.dependencies.system, {'http.js', 'url.js'}) self.assertEqual(sphereR.dependencies.resolved, {NodeDeclaration('http.js'), NodeDeclaration('url.js'), NodeDeclaration('./spherefun.js')}) self.assertEqual(sphereR.dependencies.unresolved, set())
def test_usual_node_import(self): cut = NodeDeclaration("fran/noderedis") self.assertEquals("fran/noderedis", cut.block())
def test_explicit_node_require(self): cut = NodeDeclaration("fran/noderedis/index.js") self.assertEquals("fran/noderedis", cut.block()) self.assertEquals(BlockCellName("fran/noderedis/index.js"), cut.block_cell_name())
def test_extension_namelist_with_extension(self): cut = NodeDeclaration("fran/noderedis/index.js") cut.extension_namelist() self.assertItemsEqual(["fran/noderedis/index.js"], cut._extension_name)
def test_extension_namelist_with_relative(self): cut = NodeDeclaration(".lib/queue") cut.extension_namelist() self.assertItemsEqual( [".lib/queue.json", ".lib/queue.js", ".lib/queue.node"], cut._extension_name)
def test_extension_namelist(self): cut = NodeDeclaration("fran/noderedis/index") self.assertItemsEqual([ "fran/noderedis/index.json", "fran/noderedis/index.js", "fran/noderedis/index.node" ], cut._extension_name)
def test_path_rel_require(self): cut = NodeDeclaration("./") self.assertEquals(None, cut.block())
def test_metrics_require(self): cut = NodeDeclaration("metrics") self.assertEquals(None, cut.block())
def explicit_declarations(self): result = set() if self.main: result.add(NodeDeclaration(self.main)) return result