From 42a8d609bdcd1b16493ed48e5a45fb6fbe340517 Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Wed, 20 Mar 2019 10:58:49 +0100 Subject: [PATCH] Fixed issue #150 --- .../npm-list-transitive-dependencies.json | 21 +++++++++++++++++++ tests/test_node_parser.py | 21 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 tests/files/npm-list-transitive-dependencies.json diff --git a/tests/files/npm-list-transitive-dependencies.json b/tests/files/npm-list-transitive-dependencies.json new file mode 100644 index 0000000..f81d91b --- /dev/null +++ b/tests/files/npm-list-transitive-dependencies.json @@ -0,0 +1,21 @@ +{ + "dependencies": { + "body-parser": { + "version": "1.18.2", + "dependencies": { + "debug": { + "version": "2.6.9", + "from": "debug@2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "dependencies": { + "ms": { + "version": "2.0.0", + "from": "ms@2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz" + } + } + } + } + } + } +} \ No newline at end of file diff --git a/tests/test_node_parser.py b/tests/test_node_parser.py index b2eef4c..3c5c2bb 100644 --- a/tests/test_node_parser.py +++ b/tests/test_node_parser.py @@ -22,6 +22,10 @@ def test_node_parser(): with (Path(__file__).parent / "files/npm-list.json").open('rb') as f: direct_dependencies, transitive_dependencies = \ NodeParser.parse_output_files([FileStorage(f)]) + + assert direct_dependencies is not None + assert transitive_dependencies is not None + assert direct_dependencies == { "npm:github-url-to-object:4.0.4", "npm:lodash:4.17.10", @@ -33,3 +37,20 @@ def test_node_parser(): "npm:is-url:1.2.4", "npm:semver:5.5.1" } + + +def test_node_parser_transitive_dependencies(): + """Test node parser for transitive dependencies.""" + with (Path(__file__).parent / "files/npm-list-transitive-dependencies.json").open('rb') as f: + direct_dependencies, transitive_dependencies = \ + NodeParser.parse_output_files([FileStorage(f)]) + + assert direct_dependencies is not None + assert transitive_dependencies is not None + + assert direct_dependencies == { + "npm:body-parser:1.18.2" + } + assert transitive_dependencies == { + "npm:ms:2.0.0" + }