From b046ff825556d1da14c8fdca42e8596047692269 Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Thu, 21 Mar 2019 08:11:05 +0100 Subject: [PATCH 1/4] Fix issue #160 --- tests/test_utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_utils.py b/tests/test_utils.py index cabcfb5..4523f27 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -335,3 +335,11 @@ def test_get_first_query_result(): # now first() was called, so check it assert query_result_mock.get_first_called() + + +def test_get_parser_from_ecosystem(): + """Test the function get_parser_from_ecosystem().""" + assert get_parser_from_ecosystem(None) is None + assert get_parser_from_ecosystem("unknown") is None + assert get_parser_from_ecosystem("maven") == MavenParser + assert get_parser_from_ecosystem("npm") == NodeParser From f52d0f5c71a0c2af84800a327fd4050b93dc147a Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Thu, 21 Mar 2019 08:16:14 +0100 Subject: [PATCH 2/4] Added missing import --- tests/test_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index 4523f27..1345afe 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -7,7 +7,7 @@ from src.utils import ( DatabaseIngestion, alert_user, fetch_public_key, get_session, get_session_retry, retrieve_worker_result, scan_repo, server_run_flow, validate_request_data, - fix_gremlin_output, generate_comparison, get_first_query_result + fix_gremlin_output, generate_comparison, get_first_query_result, get_parser_from_ecosystem ) from unittest.mock import patch From 519c8e0efeb8dc65afd2ca67e7c2f1b825cdfad6 Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Thu, 21 Mar 2019 08:19:17 +0100 Subject: [PATCH 3/4] Import all parsers --- tests/test_utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_utils.py b/tests/test_utils.py index 1345afe..c2c87c7 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -10,6 +10,9 @@ fix_gremlin_output, generate_comparison, get_first_query_result, get_parser_from_ecosystem ) +from src.parsers.maven_parser import MavenParser +from src.parsers.node_parser import NodeParser + from unittest.mock import patch import requests import pytest From 44b3cbaedc3f89dc2c6430e9db0629a7d62a1faf Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Thu, 21 Mar 2019 08:30:09 +0100 Subject: [PATCH 4/4] Check for class name --- tests/test_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index c2c87c7..ebe939f 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -344,5 +344,5 @@ def test_get_parser_from_ecosystem(): """Test the function get_parser_from_ecosystem().""" assert get_parser_from_ecosystem(None) is None assert get_parser_from_ecosystem("unknown") is None - assert get_parser_from_ecosystem("maven") == MavenParser - assert get_parser_from_ecosystem("npm") == NodeParser + assert get_parser_from_ecosystem("maven").__name__ == MavenParser.__name__ + assert get_parser_from_ecosystem("npm").__name__ == NodeParser.__name__