From 51ffccb620f3050b66d7b1f539ff9ba0f7f466c0 Mon Sep 17 00:00:00 2001 From: Marcel Wolf Date: Sat, 25 Apr 2015 13:28:08 +0200 Subject: [PATCH 01/13] adding new tests to the ronn_manpage_plugin --- .../plugins/ronn_manpage_plugin_tests.py | 60 ++++++++++++++++++- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/src/unittest/python/plugins/ronn_manpage_plugin_tests.py b/src/unittest/python/plugins/ronn_manpage_plugin_tests.py index 292f1a681..8d123746f 100644 --- a/src/unittest/python/plugins/ronn_manpage_plugin_tests.py +++ b/src/unittest/python/plugins/ronn_manpage_plugin_tests.py @@ -16,12 +16,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -import unittest +from unittest import TestCase from pybuilder.core import Project -from pybuilder.plugins.ronn_manpage_plugin import build_generate_manpages_command +from mock import Mock, patch +from logging import Logger +from pybuilder.plugins.ronn_manpage_plugin import ( + build_generate_manpages_command, + init_ronn_manpage_plugin, + assert_ronn_is_executable, + assert_gzip_is_executable + ) -class RonnManpagePluginTests(unittest.TestCase): +class RonnManpagePluginTests(TestCase): def test_should_generate_command_abiding_to_configuration(self): project = Project('egg') @@ -30,3 +37,50 @@ def test_should_generate_command_abiding_to_configuration(self): project.set_property("manpage_section", 1) self.assertEqual(build_generate_manpages_command(project), 'ronn -r --pipe README.md | gzip -9 > docs/man/egg.1.gz') + + +class RonnPluginInitializationTests(TestCase): + + def setUp(self): + self.project = Project("basedir") + + def test_should_leave_user_specified_properties_when_initializing_plugin(self): + + expected_properties = { + "dir_manpages": "foo", + "manpage_source": "bar", + "manpage_section": 1 + } + + for property_name, property_value in expected_properties.items(): + self.project.set_property(property_name, property_value) + + init_ronn_manpage_plugin(self.project) + + for property_name, property_value in expected_properties.items(): + self.assertEquals( + + self.project.get_property(property_name), + property_value) + + @patch('pybuilder.plugins.ronn_manpage_plugin.assert_can_execute') + def test_should_check_that_ronn_is_executable(self, mock_assert_can_execute): + + mock_logger = Mock(Logger) + + assert_ronn_is_executable(mock_logger) + mock_assert_can_execute.assert_called_with( + caller='plugin ronn_manpage_plugin', + command_and_arguments=['ronn', '--version'], + prerequisite='ronn') + + @patch('pybuilder.plugins.ronn_manpage_plugin.assert_can_execute') + def test_should_check_that_gzip_is_excecuteble(self, mock_assert_can_execute): + + mock_logger = Mock(Logger) + + assert_gzip_is_executable(mock_logger) + mock_assert_can_execute.assert_called_with( + caller="plugin ronn_manpage_plugin", + command_and_arguments=["gzip", "--version"], + prerequisite="gzip") From 1f8bc2b71af727019cbd68289d79f43a265a54c9 Mon Sep 17 00:00:00 2001 From: Marcel Wolf Date: Sat, 25 Apr 2015 17:11:40 +0200 Subject: [PATCH 02/13] adding tests to the coverage_plugin --- .../plugins/python/coverage_plugin_tests.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/unittest/python/plugins/python/coverage_plugin_tests.py diff --git a/src/unittest/python/plugins/python/coverage_plugin_tests.py b/src/unittest/python/plugins/python/coverage_plugin_tests.py new file mode 100644 index 000000000..4a7d8f674 --- /dev/null +++ b/src/unittest/python/plugins/python/coverage_plugin_tests.py @@ -0,0 +1,34 @@ +from unittest import TestCase +from pybuilder.core import Project +# from mock import Mock, patch +# from logging import Logger +from pybuilder.plugins.python.coverage_plugin import ( + init_coverage_properties + ) + + +class CoveragePluginTests(TestCase): + + def setUp(self): + self.project = Project("basedir") + + def test_should_leave_user_specified_properties_when_initializing_plugin(self): + + expected_properties = { + "coverage_threshold_warn": 70, + "coverage_break_build": True, + "coverage_reload_modules": True, + "coverage_exceptions": [], + "coverage_fork": False + } + + for property_name, property_value in expected_properties.items(): + self.project.set_property(property_name, property_value) + + init_coverage_properties(self.project) + + for property_name, property_value in expected_properties.items(): + self.assertEquals( + + self.project.get_property(property_name), + property_value) From 50ee853bf85f5a7dbb97f351c19a604862a9546a Mon Sep 17 00:00:00 2001 From: Marcel Wolf Date: Sat, 25 Apr 2015 17:12:40 +0200 Subject: [PATCH 03/13] adding tests to the snakefood_plugin --- .../plugins/python/snakefood_plugin_tests.py | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/unittest/python/plugins/python/snakefood_plugin_tests.py diff --git a/src/unittest/python/plugins/python/snakefood_plugin_tests.py b/src/unittest/python/plugins/python/snakefood_plugin_tests.py new file mode 100644 index 000000000..635648850 --- /dev/null +++ b/src/unittest/python/plugins/python/snakefood_plugin_tests.py @@ -0,0 +1,43 @@ +from unittest import TestCase +from mock import Mock, patch +from logging import Logger +from pybuilder.core import Project +from pybuilder.plugins.python.snakefood_plugin import ( + depend_on_snakefood, + check_snakefood_available, + generate_graph, + generate_pdf + ) + + +class CheckSnakeFoodAvailableTests(TestCase): + + def setUp(self): + self.project = Project("basedir") + + def test_should_set_dependency(self): + mock_project = Mock(Project) + depend_on_snakefood(mock_project) + mock_project.build_depends_on.assert_called_with('snakefood') + + @patch('pybuilder.plugins.python.snakefood_plugin.assert_can_execute') + def test_should_check_that_snakefood_is_available(self, mock_assert_can_execute): + + mock_logger = Mock(Logger) + + check_snakefood_available(mock_logger) + + mock_assert_can_execute.assert_called_with( + ('dot', '-V'), 'graphviz', 'plugin python.snakefood') + + @patch('pybuilder.plugins.python.snakefood_plugin.execute_command') + def test_should_call_generate_graph(self, mock_assert_can_execute): + report_file = "foo" + graph_file = "bar.dot" + generate_graph(report_file, graph_file) + + @patch('pybuilder.plugins.python.snakefood_plugin.execute_command') + def test_should_call_generate_pdf(self, mock_assert_can_execute): + pdf_file = "foo.pdf" + graph_file = "bar.dot" + generate_pdf(graph_file, pdf_file) From 229af4114e2e729bd00ff11b18a2d7a0ea80dfec Mon Sep 17 00:00:00 2001 From: Marcel Wolf Date: Sat, 25 Apr 2015 18:11:29 +0200 Subject: [PATCH 04/13] fixing typo in pyfix_unittest_plugin_tests --- .../python/plugins/python/pyfix_unittest_plugin_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unittest/python/plugins/python/pyfix_unittest_plugin_tests.py b/src/unittest/python/plugins/python/pyfix_unittest_plugin_tests.py index 9ef6da55d..1d1cac553 100644 --- a/src/unittest/python/plugins/python/pyfix_unittest_plugin_tests.py +++ b/src/unittest/python/plugins/python/pyfix_unittest_plugin_tests.py @@ -26,7 +26,7 @@ class InitTestSourceDirectoryTests(TestCase): @patch('pybuilder.plugins.python.pyfix_plugin_impl.execute_tests_matching') - def test_should_set_pyfix_dependencey(self, mock_execute_tests_matching): + def test_should_set_pyfix_dependency(self, mock_execute_tests_matching): mock_project = Mock(Project) From fb216cd31e2c69d858ab11836f35b42d72750a9e Mon Sep 17 00:00:00 2001 From: Marcel Wolf Date: Sun, 26 Apr 2015 11:42:15 +0200 Subject: [PATCH 05/13] adding test to the pep8_plugin --- .../python/plugins/python/pep8_plugin_tests.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/unittest/python/plugins/python/pep8_plugin_tests.py b/src/unittest/python/plugins/python/pep8_plugin_tests.py index 8e662a292..08e0df040 100644 --- a/src/unittest/python/plugins/python/pep8_plugin_tests.py +++ b/src/unittest/python/plugins/python/pep8_plugin_tests.py @@ -17,14 +17,21 @@ # limitations under the License. from unittest import TestCase +from pybuilder.core import Project from mock import Mock, patch from logging import Logger -from pybuilder.plugins.python.pep8_plugin import check_pep8_available +from pybuilder.plugins.python.pep8_plugin import ( + check_pep8_available, + init_pep8_properties + ) class CheckPep8AvailableTests(TestCase): + def setUp(self): + self.project = Project("basedir") + @patch('pybuilder.plugins.python.pep8_plugin.assert_can_execute') def test_should_check_that_pylint_can_be_executed(self, mock_assert_can_execute): @@ -34,3 +41,8 @@ def test_should_check_that_pylint_can_be_executed(self, mock_assert_can_execute) expected_command_line = ('pep8',) mock_assert_can_execute.assert_called_with(expected_command_line, 'pep8', 'plugin python.pep8') + + def test_should_set_dependency(self): + mock_project = Mock(Project) + init_pep8_properties(mock_project) + mock_project.build_depends_on.assert_called_with('pep8') From 0758bae810cc79242661421808537b5cd4867c6d Mon Sep 17 00:00:00 2001 From: Marcel Wolf Date: Sun, 26 Apr 2015 12:28:52 +0200 Subject: [PATCH 06/13] adding test to the distutils_plugin --- .../plugins/python/distutils_plugin_tests.py | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/unittest/python/plugins/python/distutils_plugin_tests.py b/src/unittest/python/plugins/python/distutils_plugin_tests.py index 97e82942e..2e4c6343d 100644 --- a/src/unittest/python/plugins/python/distutils_plugin_tests.py +++ b/src/unittest/python/plugins/python/distutils_plugin_tests.py @@ -35,7 +35,8 @@ default, render_manifest_file, build_scripts_string, - render_setup_script) + render_setup_script, + initialize_distutils_plugin) class InstallDependenciesTest(unittest.TestCase): @@ -43,6 +44,29 @@ class InstallDependenciesTest(unittest.TestCase): def setUp(self): self.project = Project(".") + def test_should_generate_command_abiding_to_configuration(self): + + expected_properties = { + "distutils_commands": ["sdist", "bdist_dumb"], + "distutils_issue8876_workaround_enabled": False, + "distutils_classifiers": [ + "Development Status :: 3 - Alpha", + "Programming Language :: Python" + ], + "distutils_use_setuptools": True + } + + for property_name, property_value in expected_properties.items(): + self.project.set_property(property_name, property_value) + + initialize_distutils_plugin(self.project) + + for property_name, property_value in expected_properties.items(): + self.assertEquals( + + self.project.get_property(property_name), + property_value) + def test_should_return_empty_string_when_no_dependency_is_given(self): self.assertEqual("", build_install_dependencies_string(self.project)) From f8da8e04408a633cafab32c5575d42c43c81e36a Mon Sep 17 00:00:00 2001 From: Marcel Wolf Date: Sun, 26 Apr 2015 12:29:08 +0200 Subject: [PATCH 07/13] adding test to the integrationtest_plugin --- .../python/integrationtest_plugin_tests.py | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/unittest/python/plugins/python/integrationtest_plugin_tests.py b/src/unittest/python/plugins/python/integrationtest_plugin_tests.py index e31c12c2a..71004a2f7 100644 --- a/src/unittest/python/plugins/python/integrationtest_plugin_tests.py +++ b/src/unittest/python/plugins/python/integrationtest_plugin_tests.py @@ -25,15 +25,40 @@ from mock import patch from pybuilder.core import Project -from pybuilder.plugins.python.integrationtest_plugin import (TaskPoolProgress, - add_additional_environment_keys, - ConsumingQueue) +from pybuilder.plugins.python.integrationtest_plugin import ( + TaskPoolProgress, + add_additional_environment_keys, + ConsumingQueue, + init_test_source_directory + ) class TaskPoolProgressTests(unittest.TestCase): def setUp(self): self.progress = TaskPoolProgress(42, 8) + self.project = Project("basedir") + + def test_should_generate_command_abiding_to_configuration(self): + + expected_properties = { + "dir_source_integrationtest_python": "src/integrationtest/python", + "integrationtest_file_glob": "*_tests.py", + "integrationtest_file_suffix": None, + "integrationtest_additional_environment": {}, + "integrationtest_inherit_environment": False, + "integrationtest_always_verbose": False + } + for property_name, property_value in expected_properties.items(): + self.project.set_property(property_name, property_value) + + init_test_source_directory(self.project) + + for property_name, property_value in expected_properties.items(): + self.assertEquals( + + self.project.get_property(property_name), + property_value) def test_should_create_new_progress(self): self.assertEqual(self.progress.workers_count, 8) From 0e4068d7c0942c957e3827b8309ab626c1ddc865 Mon Sep 17 00:00:00 2001 From: Marcel Wolf Date: Sun, 26 Apr 2015 16:53:46 +0200 Subject: [PATCH 08/13] adding tests to the flake8_plugin --- .../plugins/python/flake8_plugin_tests.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/unittest/python/plugins/python/flake8_plugin_tests.py diff --git a/src/unittest/python/plugins/python/flake8_plugin_tests.py b/src/unittest/python/plugins/python/flake8_plugin_tests.py new file mode 100644 index 000000000..d45b77d9f --- /dev/null +++ b/src/unittest/python/plugins/python/flake8_plugin_tests.py @@ -0,0 +1,35 @@ +from unittest import TestCase +from pybuilder.core import Project +from mock import Mock +from pybuilder.plugins.python.flake8_plugin import initialize_flake8_plugin + + +class FlakePluginInitializationTests(TestCase): + + def setUp(self): + self.project = Project("basedir") + + def test_should_set_dependency(self): + mock_project = Mock(Project) + initialize_flake8_plugin(mock_project) + mock_project.build_depends_on.assert_called_with('flake8') + + def test_should_leave_user_specified_properties_when_initializing_plugin(self): + + expected_properties = { + "flake8_break_build": False, + "flake8_max_line_length": 120, + "flake8_exclude_patterns": None, + "flake8_include_test_sources": False, + "flake8_include_scripts": False + } + for property_name, property_value in expected_properties.items(): + self.project.set_property(property_name, property_value) + + initialize_flake8_plugin(self.project) + + for property_name, property_value in expected_properties.items(): + self.assertEquals( + + self.project.get_property(property_name), + property_value) From 49d04e68ea24a4a6d9fdc34c8bcaf3323aefd6db Mon Sep 17 00:00:00 2001 From: Marcel Wolf Date: Sun, 26 Apr 2015 21:36:46 +0200 Subject: [PATCH 09/13] removing unused imports --- src/unittest/python/plugins/python/coverage_plugin_tests.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/unittest/python/plugins/python/coverage_plugin_tests.py b/src/unittest/python/plugins/python/coverage_plugin_tests.py index 4a7d8f674..1074f79d0 100644 --- a/src/unittest/python/plugins/python/coverage_plugin_tests.py +++ b/src/unittest/python/plugins/python/coverage_plugin_tests.py @@ -1,7 +1,5 @@ from unittest import TestCase from pybuilder.core import Project -# from mock import Mock, patch -# from logging import Logger from pybuilder.plugins.python.coverage_plugin import ( init_coverage_properties ) From 4b688b9b3e7fc29a82887cb64a55960529728ea6 Mon Sep 17 00:00:00 2001 From: Marcel Wolf Date: Mon, 27 Apr 2015 08:02:25 +0200 Subject: [PATCH 10/13] adding missing assertion back to snakefood_plugin_tests --- src/unittest/python/plugins/python/snakefood_plugin_tests.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/unittest/python/plugins/python/snakefood_plugin_tests.py b/src/unittest/python/plugins/python/snakefood_plugin_tests.py index 635648850..65e301963 100644 --- a/src/unittest/python/plugins/python/snakefood_plugin_tests.py +++ b/src/unittest/python/plugins/python/snakefood_plugin_tests.py @@ -35,9 +35,13 @@ def test_should_call_generate_graph(self, mock_assert_can_execute): report_file = "foo" graph_file = "bar.dot" generate_graph(report_file, graph_file) + mock_assert_can_execute.assert_called_with( + ["sfood-graph", report_file], graph_file) @patch('pybuilder.plugins.python.snakefood_plugin.execute_command') def test_should_call_generate_pdf(self, mock_assert_can_execute): pdf_file = "foo.pdf" graph_file = "bar.dot" generate_pdf(graph_file, pdf_file) + mock_assert_can_execute.assert_called_with( + ["dot", "-Tpdf", graph_file], pdf_file) From 4b72eb1dc3975f78f98ed3d6d201d81f44acadd6 Mon Sep 17 00:00:00 2001 From: locolupo Date: Mon, 27 Apr 2015 09:40:22 +0200 Subject: [PATCH 11/13] adding test to snakefood_plugin, small change to the plugin itself --- .../pybuilder/plugins/python/snakefood_plugin.py | 4 ++++ .../python/plugins/python/snakefood_plugin_tests.py | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/main/python/pybuilder/plugins/python/snakefood_plugin.py b/src/main/python/pybuilder/plugins/python/snakefood_plugin.py index 3fcf8cf81..455a466fb 100644 --- a/src/main/python/pybuilder/plugins/python/snakefood_plugin.py +++ b/src/main/python/pybuilder/plugins/python/snakefood_plugin.py @@ -30,6 +30,10 @@ def check_snakefood_available(logger): assert_can_execute(("sfood", "-h"), "sfood", "plugin python.snakefood") logger.debug("snakefood has been found") + +@before("render_snakefood_report") +def check_graphviz_available(logger): + logger.debug("Checking availability of graphviz") assert_can_execute(("dot", "-V"), "graphviz", "plugin python.snakefood") logger.debug("graphviz has been found") diff --git a/src/unittest/python/plugins/python/snakefood_plugin_tests.py b/src/unittest/python/plugins/python/snakefood_plugin_tests.py index 65e301963..84fcf30c9 100644 --- a/src/unittest/python/plugins/python/snakefood_plugin_tests.py +++ b/src/unittest/python/plugins/python/snakefood_plugin_tests.py @@ -5,6 +5,7 @@ from pybuilder.plugins.python.snakefood_plugin import ( depend_on_snakefood, check_snakefood_available, + check_graphviz_available, generate_graph, generate_pdf ) @@ -27,6 +28,16 @@ def test_should_check_that_snakefood_is_available(self, mock_assert_can_execute) check_snakefood_available(mock_logger) + mock_assert_can_execute.assert_called_with( + ("sfood", "-h"), "sfood", "plugin python.snakefood") + + @patch('pybuilder.plugins.python.snakefood_plugin.assert_can_execute') + def test_should_check_that_graphviz_is_available(self, mock_assert_can_execute): + + mock_logger = Mock(Logger) + + check_graphviz_available(mock_logger) + mock_assert_can_execute.assert_called_with( ('dot', '-V'), 'graphviz', 'plugin python.snakefood') From 4a4f1ecac09725c7b9c79fefd045216673648b95 Mon Sep 17 00:00:00 2001 From: Marcel Wolf Date: Thu, 23 Jul 2015 16:58:07 +0200 Subject: [PATCH 12/13] better tests for project properties and some flake8 foo --- .../plugins/python/coverage_plugin_tests.py | 24 ++++++---- .../plugins/python/distutils_plugin_tests.py | 44 ++++++++++++------- .../python/integrationtest_plugin_tests.py | 26 ++++++----- .../plugins/python/pep8_plugin_tests.py | 3 -- .../plugins/python/snakefood_plugin_tests.py | 16 +++---- .../plugins/python/sphinx_plugin_tests.py | 24 ++++++---- .../plugins/ronn_manpage_plugin_tests.py | 2 +- 7 files changed, 83 insertions(+), 56 deletions(-) diff --git a/src/unittest/python/plugins/python/coverage_plugin_tests.py b/src/unittest/python/plugins/python/coverage_plugin_tests.py index 1074f79d0..e556af67f 100644 --- a/src/unittest/python/plugins/python/coverage_plugin_tests.py +++ b/src/unittest/python/plugins/python/coverage_plugin_tests.py @@ -2,7 +2,7 @@ from pybuilder.core import Project from pybuilder.plugins.python.coverage_plugin import ( init_coverage_properties - ) +) class CoveragePluginTests(TestCase): @@ -13,11 +13,11 @@ def setUp(self): def test_should_leave_user_specified_properties_when_initializing_plugin(self): expected_properties = { - "coverage_threshold_warn": 70, - "coverage_break_build": True, - "coverage_reload_modules": True, - "coverage_exceptions": [], - "coverage_fork": False + "coverage_threshold_warn": 120, + "coverage_break_build": False, + "coverage_reload_modules": False, + "coverage_exceptions": ["foo"], + "coverage_fork": True } for property_name, property_value in expected_properties.items(): @@ -27,6 +27,12 @@ def test_should_leave_user_specified_properties_when_initializing_plugin(self): for property_name, property_value in expected_properties.items(): self.assertEquals( - - self.project.get_property(property_name), - property_value) + self.project.get_property("coverage_threshold_warn"), 120) + self.assertEquals( + self.project.get_property("coverage_break_build"), False) + self.assertEquals( + self.project.get_property("coverage_reload_modules"), False) + self.assertEquals( + self.project.get_property("coverage_exceptions"), ["foo"]) + self.assertEquals( + self.project.get_property("coverage_fork"), True) diff --git a/src/unittest/python/plugins/python/distutils_plugin_tests.py b/src/unittest/python/plugins/python/distutils_plugin_tests.py index 2e4c6343d..888fecea0 100644 --- a/src/unittest/python/plugins/python/distutils_plugin_tests.py +++ b/src/unittest/python/plugins/python/distutils_plugin_tests.py @@ -44,16 +44,16 @@ class InstallDependenciesTest(unittest.TestCase): def setUp(self): self.project = Project(".") - def test_should_generate_command_abiding_to_configuration(self): + def test_should_leave_user_specified_properties_when_initializing_plugin(self): expected_properties = { - "distutils_commands": ["sdist", "bdist_dumb"], - "distutils_issue8876_workaround_enabled": False, + "distutils_commands": ["foo", "bar"], + "distutils_issue8876_workaround_enabled": True, "distutils_classifiers": [ - "Development Status :: 3 - Alpha", - "Programming Language :: Python" + "Development Status :: 3 - Beta", + "Programming Language :: Rust" ], - "distutils_use_setuptools": True + "distutils_use_setuptools": False } for property_name, property_value in expected_properties.items(): @@ -63,9 +63,14 @@ def test_should_generate_command_abiding_to_configuration(self): for property_name, property_value in expected_properties.items(): self.assertEquals( - - self.project.get_property(property_name), - property_value) + self.project.get_property("distutils_commands"), ["foo", "bar"]) + self.assertEquals( + self.project.get_property("distutils_issue8876_workaround_enabled"), True) + self.assertEquals( + self.project.get_property("distutils_classifiers"), ["Development Status :: 3 - Beta", + "Programming Language :: Rust"]) + self.assertEquals( + self.project.get_property("distutils_use_setuptools"), False) def test_should_return_empty_string_when_no_dependency_is_given(self): self.assertEqual("", build_install_dependencies_string(self.project)) @@ -143,7 +148,8 @@ def test_should_ignore_comments_with_leading_space_from_requirements(self, mock_ def test_should_ignore_editable_urls_from_requirements(self, mock_open): mock_open.return_value = MagicMock(spec=TYPE_FILE) handle = mock_open.return_value.__enter__.return_value - handle.readlines.return_value = ["foo", "-e git+https://github.com/someuser/someproject.git#egg=some_package"] + handle.readlines.return_value = [ + "foo", "-e git+https://github.com/someuser/someproject.git#egg=some_package"] self.project.depends_on_requirements("requirements.txt") self.assertEqual( @@ -153,7 +159,8 @@ def test_should_ignore_editable_urls_from_requirements(self, mock_open): def test_should_ignore_expanded_editable_urls_from_requirements(self, mock_open): mock_open.return_value = MagicMock(spec=TYPE_FILE) handle = mock_open.return_value.__enter__.return_value - handle.readlines.return_value = ["foo", "--editable git+https://github.com/someuser/someproject.git#egg=some_package"] + handle.readlines.return_value = [ + "foo", "--editable git+https://github.com/someuser/someproject.git#egg=some_package"] self.project.depends_on_requirements("requirements.txt") self.assertEqual( @@ -218,7 +225,8 @@ def test_should_use_editable_urls_from_requirements_combined_with_url_dependenci handle = mock_open.return_value.__enter__.return_value handle.readlines.return_value = [ "-e svn+https://github.com/someuser/someproject#egg=some_package"] - self.project.depends_on("jedi", url="git+https://github.com/davidhalter/jedi") + self.project.depends_on( + "jedi", url="git+https://github.com/davidhalter/jedi") self.project.depends_on_requirements("requirements.txt") self.assertEqual( @@ -318,14 +326,16 @@ def setUp(self): self.project = create_project() def test_should_remove_hardlink_capabilities_when_workaround_is_enabled(self): - self.project.set_property("distutils_issue8876_workaround_enabled", True) + self.project.set_property( + "distutils_issue8876_workaround_enabled", True) actual_setup_script = render_setup_script(self.project) self.assertTrue("import os\ndel os.link\n" in actual_setup_script) def test_should_not_remove_hardlink_capabilities_when_workaround_is_disabled(self): - self.project.set_property("distutils_issue8876_workaround_enabled", False) + self.project.set_property( + "distutils_issue8876_workaround_enabled", False) actual_setup_script = render_setup_script(self.project) @@ -334,7 +344,8 @@ def test_should_not_remove_hardlink_capabilities_when_workaround_is_disabled(sel def test_should_render_build_scripts_properly_when_dir_scripts_is_provided(self): self.project.set_property("dir_dist_scripts", 'scripts') actual_build_script = build_scripts_string(self.project) - self.assertEquals("['scripts/spam', 'scripts/eggs']", actual_build_script) + self.assertEquals( + "['scripts/spam', 'scripts/eggs']", actual_build_script) def test_should_render_setup_file(self): actual_setup_script = render_setup_script(self.project) @@ -389,7 +400,8 @@ def test_should_render_runtime_dependencies_when_requirements_file_used(self, mo actual_setup_script = render_setup_script(self.project) - self.assertTrue('install_requires = [ "sometool", "foo", "bar" ],' in actual_setup_script) + self.assertTrue( + 'install_requires = [ "sometool", "foo", "bar" ],' in actual_setup_script) class RenderManifestFileTest(unittest.TestCase): diff --git a/src/unittest/python/plugins/python/integrationtest_plugin_tests.py b/src/unittest/python/plugins/python/integrationtest_plugin_tests.py index 71004a2f7..a82b10ac1 100644 --- a/src/unittest/python/plugins/python/integrationtest_plugin_tests.py +++ b/src/unittest/python/plugins/python/integrationtest_plugin_tests.py @@ -39,15 +39,15 @@ def setUp(self): self.progress = TaskPoolProgress(42, 8) self.project = Project("basedir") - def test_should_generate_command_abiding_to_configuration(self): + def test_should_leave_user_specified_properties_when_initializing_plugin(self): expected_properties = { - "dir_source_integrationtest_python": "src/integrationtest/python", - "integrationtest_file_glob": "*_tests.py", - "integrationtest_file_suffix": None, - "integrationtest_additional_environment": {}, - "integrationtest_inherit_environment": False, - "integrationtest_always_verbose": False + "dir_source_integrationtest_python": "foo/bar/python", + "integrationtest_file_glob": "*foo.py", + "integrationtest_file_suffix": True, + "integrationtest_additional_environment": {"env3": "foo"}, + "integrationtest_inherit_environment": True, + "integrationtest_always_verbose": True } for property_name, property_value in expected_properties.items(): self.project.set_property(property_name, property_value) @@ -56,9 +56,15 @@ def test_should_generate_command_abiding_to_configuration(self): for property_name, property_value in expected_properties.items(): self.assertEquals( - - self.project.get_property(property_name), - property_value) + self.project.get_property("dir_source_integrationtest_python"), "foo/bar/python") + self.assertEquals( + self.project.get_property("integrationtest_file_glob"), "*foo.py") + self.assertEquals( + self.project.get_property("integrationtest_file_suffix"), True) + self.assertEquals( + self.project.get_property("integrationtest_additional_environment"), {"env3": "foo"}), + self.assertEquals( + self.project.get_property("integrationtest_always_verbose"), True) def test_should_create_new_progress(self): self.assertEqual(self.progress.workers_count, 8) diff --git a/src/unittest/python/plugins/python/pep8_plugin_tests.py b/src/unittest/python/plugins/python/pep8_plugin_tests.py index 08e0df040..90edabdb5 100644 --- a/src/unittest/python/plugins/python/pep8_plugin_tests.py +++ b/src/unittest/python/plugins/python/pep8_plugin_tests.py @@ -29,9 +29,6 @@ class CheckPep8AvailableTests(TestCase): - def setUp(self): - self.project = Project("basedir") - @patch('pybuilder.plugins.python.pep8_plugin.assert_can_execute') def test_should_check_that_pylint_can_be_executed(self, mock_assert_can_execute): diff --git a/src/unittest/python/plugins/python/snakefood_plugin_tests.py b/src/unittest/python/plugins/python/snakefood_plugin_tests.py index 84fcf30c9..a48517694 100644 --- a/src/unittest/python/plugins/python/snakefood_plugin_tests.py +++ b/src/unittest/python/plugins/python/snakefood_plugin_tests.py @@ -22,37 +22,37 @@ def test_should_set_dependency(self): mock_project.build_depends_on.assert_called_with('snakefood') @patch('pybuilder.plugins.python.snakefood_plugin.assert_can_execute') - def test_should_check_that_snakefood_is_available(self, mock_assert_can_execute): + def test_should_check_that_snakefood_is_available(self, mock_execute_command): mock_logger = Mock(Logger) check_snakefood_available(mock_logger) - mock_assert_can_execute.assert_called_with( + mock_execute_command.assert_called_with( ("sfood", "-h"), "sfood", "plugin python.snakefood") @patch('pybuilder.plugins.python.snakefood_plugin.assert_can_execute') - def test_should_check_that_graphviz_is_available(self, mock_assert_can_execute): + def test_should_check_that_graphviz_is_available(self, mock_execute_command): mock_logger = Mock(Logger) check_graphviz_available(mock_logger) - mock_assert_can_execute.assert_called_with( + mock_execute_command.assert_called_with( ('dot', '-V'), 'graphviz', 'plugin python.snakefood') @patch('pybuilder.plugins.python.snakefood_plugin.execute_command') - def test_should_call_generate_graph(self, mock_assert_can_execute): + def test_should_call_generate_graph(self, mock_execute_command): report_file = "foo" graph_file = "bar.dot" generate_graph(report_file, graph_file) - mock_assert_can_execute.assert_called_with( + mock_execute_command.assert_called_with( ["sfood-graph", report_file], graph_file) @patch('pybuilder.plugins.python.snakefood_plugin.execute_command') - def test_should_call_generate_pdf(self, mock_assert_can_execute): + def test_should_call_generate_pdf(self, mock_execute_command): pdf_file = "foo.pdf" graph_file = "bar.dot" generate_pdf(graph_file, pdf_file) - mock_assert_can_execute.assert_called_with( + mock_execute_command.assert_called_with( ["dot", "-Tpdf", graph_file], pdf_file) diff --git a/src/unittest/python/plugins/python/sphinx_plugin_tests.py b/src/unittest/python/plugins/python/sphinx_plugin_tests.py index e03aaba65..11b7cfad3 100644 --- a/src/unittest/python/plugins/python/sphinx_plugin_tests.py +++ b/src/unittest/python/plugins/python/sphinx_plugin_tests.py @@ -26,8 +26,7 @@ assert_sphinx_quickstart_is_available, get_sphinx_build_command, get_sphinx_quickstart_command, - initialize_sphinx_plugin - ) + initialize_sphinx_plugin) class CheckSphinxAvailableTests(TestCase): @@ -91,13 +90,20 @@ def test_should_set_default_values_when_initializing_plugin(self): self.project.set_property("sphinx_project_name", "foo") self.project.set_property("sphinx_project_version", "1.0") - self.assertEquals(self.project.get_property("sphinx_source_dir"), "docs") - self.assertEquals(self.project.get_property("sphinx_output_dir"), "docs/_build/") - self.assertEquals(self.project.get_property("sphinx_config_path"), "docs") - self.assertEquals(self.project.get_property("sphinx_doc_author"), 'John Doe, Jane Doe') - self.assertEquals(self.project.get_property("sphinx_doc_builder"), "html") - self.assertEquals(self.project.get_property("sphinx_project_name"), "foo") - self.assertEquals(self.project.get_property("sphinx_project_version"), "1.0") + self.assertEquals( + self.project.get_property("sphinx_source_dir"), "docs") + self.assertEquals( + self.project.get_property("sphinx_output_dir"), "docs/_build/") + self.assertEquals( + self.project.get_property("sphinx_config_path"), "docs") + self.assertEquals( + self.project.get_property("sphinx_doc_author"), 'John Doe, Jane Doe') + self.assertEquals( + self.project.get_property("sphinx_doc_builder"), "html") + self.assertEquals( + self.project.get_property("sphinx_project_name"), "foo") + self.assertEquals( + self.project.get_property("sphinx_project_version"), "1.0") class SphinxBuildCommandTests(TestCase): diff --git a/src/unittest/python/plugins/ronn_manpage_plugin_tests.py b/src/unittest/python/plugins/ronn_manpage_plugin_tests.py index 8d123746f..f926be389 100644 --- a/src/unittest/python/plugins/ronn_manpage_plugin_tests.py +++ b/src/unittest/python/plugins/ronn_manpage_plugin_tests.py @@ -75,7 +75,7 @@ def test_should_check_that_ronn_is_executable(self, mock_assert_can_execute): prerequisite='ronn') @patch('pybuilder.plugins.ronn_manpage_plugin.assert_can_execute') - def test_should_check_that_gzip_is_excecuteble(self, mock_assert_can_execute): + def test_should_check_that_gzip_is_executable(self, mock_assert_can_execute): mock_logger = Mock(Logger) From 0541972ef6304b41f31986fd620dc2d905a655c5 Mon Sep 17 00:00:00 2001 From: Marcel Wolf Date: Thu, 23 Jul 2015 17:12:37 +0200 Subject: [PATCH 13/13] renaming integration_test_plugin function --- .../python/pybuilder/plugins/python/integrationtest_plugin.py | 2 +- .../python/plugins/python/integrationtest_plugin_tests.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/python/pybuilder/plugins/python/integrationtest_plugin.py b/src/main/python/pybuilder/plugins/python/integrationtest_plugin.py index f8eb9bf97..0f87a6b7d 100644 --- a/src/main/python/pybuilder/plugins/python/integrationtest_plugin.py +++ b/src/main/python/pybuilder/plugins/python/integrationtest_plugin.py @@ -36,7 +36,7 @@ @init -def init_test_source_directory(project): +def initialize_integrationtest_plugin(project): project.set_property_if_unset( "dir_source_integrationtest_python", "src/integrationtest/python") project.set_property_if_unset("integrationtest_file_glob", "*_tests.py") diff --git a/src/unittest/python/plugins/python/integrationtest_plugin_tests.py b/src/unittest/python/plugins/python/integrationtest_plugin_tests.py index a82b10ac1..1dbf14e65 100644 --- a/src/unittest/python/plugins/python/integrationtest_plugin_tests.py +++ b/src/unittest/python/plugins/python/integrationtest_plugin_tests.py @@ -29,7 +29,7 @@ TaskPoolProgress, add_additional_environment_keys, ConsumingQueue, - init_test_source_directory + initialize_integrationtest_plugin ) @@ -52,7 +52,7 @@ def test_should_leave_user_specified_properties_when_initializing_plugin(self): for property_name, property_value in expected_properties.items(): self.project.set_property(property_name, property_value) - init_test_source_directory(self.project) + initialize_integrationtest_plugin(self.project) for property_name, property_value in expected_properties.items(): self.assertEquals(