-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
297 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/unittest/python/plugins/python/coverage_plugin_tests.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from unittest import TestCase | ||
from pybuilder.core import Project | ||
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": 120, | ||
"coverage_break_build": False, | ||
"coverage_reload_modules": False, | ||
"coverage_exceptions": ["foo"], | ||
"coverage_fork": True | ||
} | ||
|
||
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("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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/unittest/python/plugins/python/snakefood_plugin_tests.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
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, | ||
check_graphviz_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_execute_command): | ||
|
||
mock_logger = Mock(Logger) | ||
|
||
check_snakefood_available(mock_logger) | ||
|
||
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_execute_command): | ||
|
||
mock_logger = Mock(Logger) | ||
|
||
check_graphviz_available(mock_logger) | ||
|
||
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_execute_command): | ||
report_file = "foo" | ||
graph_file = "bar.dot" | ||
generate_graph(report_file, graph_file) | ||
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_execute_command): | ||
pdf_file = "foo.pdf" | ||
graph_file = "bar.dot" | ||
generate_pdf(graph_file, pdf_file) | ||
mock_execute_command.assert_called_with( | ||
["dot", "-Tpdf", graph_file], pdf_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.