From ebcee1420fb9ac9a1a6150954637102d5ff30e77 Mon Sep 17 00:00:00 2001 From: Bogdan Sikora Date: Wed, 23 Sep 2020 15:45:57 -0500 Subject: [PATCH 1/3] feat: Maven simple E2E test added --- tests/run_license/__init__.py | 0 tests/run_license/test_maven.py | 45 +++++++++++++++++++++++++ tests/test_data/__init__.py | 0 tests/test_data/pom.xml | 59 +++++++++++++++++++++++++++++++++ 4 files changed, 104 insertions(+) create mode 100644 tests/run_license/__init__.py create mode 100644 tests/run_license/test_maven.py create mode 100644 tests/test_data/__init__.py create mode 100644 tests/test_data/pom.xml diff --git a/tests/run_license/__init__.py b/tests/run_license/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/run_license/test_maven.py b/tests/run_license/test_maven.py new file mode 100644 index 0000000..2166631 --- /dev/null +++ b/tests/run_license/test_maven.py @@ -0,0 +1,45 @@ +import unittest + +from license_sh.commands.run_license_sh import run_license_sh +from anytree.importer import JsonImporter +from unittest.mock import patch +from tests import test_data +from importlib import resources + +ARGUMENTS = { + '--config': None, + '--debug': False, + '--dependencies': False, + '--help': False, + '--interactive': False, + '--output': 'console', + '--project': None, + '--tree': False, + '--version': False, + '': None, + 'config': False +} + + +class MavenCase(unittest.TestCase): + @patch('builtins.print') + def test_valid_json(self, print_mock): + with resources.path(test_data, "") as test_data_path: + with self.assertRaises(SystemExit): + run_license_sh({**ARGUMENTS, **{ + '--output': 'json', + '': test_data_path, + '--project': 'maven' + }}) + calls = print_mock.call_args_list + + std_out = "" + for call in calls: + file_arg = call.kwargs.get('file', None) + if not file_arg: + std_out += ''.join(call.args) + self.assertTrue(bool(JsonImporter().import_(std_out))) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/test_data/__init__.py b/tests/test_data/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_data/pom.xml b/tests/test_data/pom.xml new file mode 100644 index 0000000..5a068f7 --- /dev/null +++ b/tests/test_data/pom.xml @@ -0,0 +1,59 @@ + + + 4.0.0 + sh.license + 0.9.23 + license + license-sh maven test + jar + + + UTF-8 + + + + + junit + junit + 4.12 + test + + + org.javassist + javassist + 3.22.0-GA + true + + + com.fasterxml.jackson.core + jackson-annotations + 2.9.5 + true + + + com.fasterxml.jackson.core + jackson-databind + 2.9.5 + true + + + com.google.code.gson + gson + 2.8.3 + true + + + org.openjdk.jmh + jmh-core + 1.20 + test + + + org.openjdk.jmh + jmh-generator-annprocess + 1.20 + test + + + From 630ca6df84e42b8d6af8a8af7fd6776cebd9ecf1 Mon Sep 17 00:00:00 2001 From: Bogdan Sikora Date: Wed, 23 Sep 2020 16:07:57 -0500 Subject: [PATCH 2/3] feat: End 2 end test moved --- .github/workflows/python-build.yml | 3 +++ Pipfile | 1 + {tests/run_license => test_e2e}/__init__.py | 0 {tests => test_e2e}/test_data/__init__.py | 0 {tests => test_e2e}/test_data/pom.xml | 0 {tests/run_license => test_e2e}/test_maven.py | 2 +- 6 files changed, 5 insertions(+), 1 deletion(-) rename {tests/run_license => test_e2e}/__init__.py (100%) rename {tests => test_e2e}/test_data/__init__.py (100%) rename {tests => test_e2e}/test_data/pom.xml (100%) rename {tests/run_license => test_e2e}/test_maven.py (97%) diff --git a/.github/workflows/python-build.yml b/.github/workflows/python-build.yml index b3be771..f5162ab 100644 --- a/.github/workflows/python-build.yml +++ b/.github/workflows/python-build.yml @@ -38,3 +38,6 @@ jobs: run: | pip install mypy pipenv run check-types + - name: End-to-End tests + run: | + pipenv run test-e2e diff --git a/Pipfile b/Pipfile index e429f4e..1459c72 100644 --- a/Pipfile +++ b/Pipfile @@ -27,3 +27,4 @@ allow_prereleases = true lint = "flake8 . --count --max-complexity=10 --max-line-length=127 --statistics" check-types = "mypy ./license-sh" test = "python -m unittest" +test-e2e = "python -m unittest discover -s ./test_e2e" diff --git a/tests/run_license/__init__.py b/test_e2e/__init__.py similarity index 100% rename from tests/run_license/__init__.py rename to test_e2e/__init__.py diff --git a/tests/test_data/__init__.py b/test_e2e/test_data/__init__.py similarity index 100% rename from tests/test_data/__init__.py rename to test_e2e/test_data/__init__.py diff --git a/tests/test_data/pom.xml b/test_e2e/test_data/pom.xml similarity index 100% rename from tests/test_data/pom.xml rename to test_e2e/test_data/pom.xml diff --git a/tests/run_license/test_maven.py b/test_e2e/test_maven.py similarity index 97% rename from tests/run_license/test_maven.py rename to test_e2e/test_maven.py index 2166631..59f9c4c 100644 --- a/tests/run_license/test_maven.py +++ b/test_e2e/test_maven.py @@ -3,7 +3,7 @@ from license_sh.commands.run_license_sh import run_license_sh from anytree.importer import JsonImporter from unittest.mock import patch -from tests import test_data +from test_e2e import test_data from importlib import resources ARGUMENTS = { From c5ce40f3b8a2b1b7f6a8292755a04218284ba4d4 Mon Sep 17 00:00:00 2001 From: Bogdan Sikora Date: Wed, 23 Sep 2020 16:12:42 -0500 Subject: [PATCH 3/3] fix: End 2 end test start split --- Pipfile | 4 ++-- {test_e2e => tests_e2e}/__init__.py | 0 {test_e2e => tests_e2e}/test_data/__init__.py | 0 {test_e2e => tests_e2e}/test_data/pom.xml | 0 {test_e2e => tests_e2e}/test_maven.py | 2 +- 5 files changed, 3 insertions(+), 3 deletions(-) rename {test_e2e => tests_e2e}/__init__.py (100%) rename {test_e2e => tests_e2e}/test_data/__init__.py (100%) rename {test_e2e => tests_e2e}/test_data/pom.xml (100%) rename {test_e2e => tests_e2e}/test_maven.py (97%) diff --git a/Pipfile b/Pipfile index 1459c72..2df16be 100644 --- a/Pipfile +++ b/Pipfile @@ -26,5 +26,5 @@ allow_prereleases = true [scripts] lint = "flake8 . --count --max-complexity=10 --max-line-length=127 --statistics" check-types = "mypy ./license-sh" -test = "python -m unittest" -test-e2e = "python -m unittest discover -s ./test_e2e" +test = "python -m unittest discover -s ./tests" +test-e2e = "python -m unittest discover -s ./tests_e2e" diff --git a/test_e2e/__init__.py b/tests_e2e/__init__.py similarity index 100% rename from test_e2e/__init__.py rename to tests_e2e/__init__.py diff --git a/test_e2e/test_data/__init__.py b/tests_e2e/test_data/__init__.py similarity index 100% rename from test_e2e/test_data/__init__.py rename to tests_e2e/test_data/__init__.py diff --git a/test_e2e/test_data/pom.xml b/tests_e2e/test_data/pom.xml similarity index 100% rename from test_e2e/test_data/pom.xml rename to tests_e2e/test_data/pom.xml diff --git a/test_e2e/test_maven.py b/tests_e2e/test_maven.py similarity index 97% rename from test_e2e/test_maven.py rename to tests_e2e/test_maven.py index 59f9c4c..c3fbfc0 100644 --- a/test_e2e/test_maven.py +++ b/tests_e2e/test_maven.py @@ -3,7 +3,7 @@ from license_sh.commands.run_license_sh import run_license_sh from anytree.importer import JsonImporter from unittest.mock import patch -from test_e2e import test_data +from tests_e2e import test_data from importlib import resources ARGUMENTS = {