diff --git a/.travis.yml b/.travis.yml index 75649ec..4e275e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,5 +8,10 @@ install: script: - pytest test/ -v - pycodestyle *.py +after_script: + - py.test --cov-report term --cov=. + - codeclimate-test-reporter + - coverage xml + - python-codacy-coverage -r coverage.xml notification: email: false diff --git a/conventions/symphony_cmf.py b/conventions/symphony_cmf.py index 6acd455..dc39b8f 100644 --- a/conventions/symphony_cmf.py +++ b/conventions/symphony_cmf.py @@ -1,3 +1,4 @@ def symphony_convention(tag, msg): tag = tag.capitalize() composed = "[%s] %s\n" % (tag, msg) + return composed diff --git a/generator.py b/generator.py index 9e38a0a..8b5eaa7 100755 --- a/generator.py +++ b/generator.py @@ -35,19 +35,18 @@ def main(debug_mode=False): convention = 'none' if convention == 'none': + print('You are not using a convention') commit_message = just_message() else: + print('You are using the %s convention' % convention) tag, msg = get_text() if convention == 'angular' or convention == 'karma': - print('You are using the %s convention' % convention) context = get_context() commit_message = angular_convention(tag, msg, context) elif convention == 'changelog': - print('You are using the %s convention' % convention) commit_message = changelog_convention(tag, msg) elif convention == 'symphony': - print('You are using the %s convention' % convention) commit_message = symphony_convention(tag, msg) commit_message += gen_co_author(args.co_author) @@ -88,7 +87,8 @@ def main(debug_mode=False): parser.print_help() -parser = parser_cli() -args = parser.parse_args() -debug('args variable', args, args.debug) -main(args.debug) +if __name__ == '__main__': + parser = parser_cli() + args = parser.parse_args() + debug('args variable', args, args.debug) + main(args.debug) diff --git a/requirements.txt b/requirements.txt index a3f4335..e048d91 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,7 @@ pyyaml==3.13 pytest==3.8.1 pycodestyle==2.4.0 argparse==1.4.0 +coverage==4.3 +pytest-cov==2.0.0 +codeclimate-test-reporter +codacy-coverage==1.3 diff --git a/test/test_conventions.py b/test/test_conventions.py index c3ad1c3..e5b91a4 100644 --- a/test/test_conventions.py +++ b/test/test_conventions.py @@ -7,41 +7,36 @@ def test_angular_convention_with_context(): message = angular.angular_convention('TAG', 'message', 'context') - if not ('tag(context): message\n'): raise AssertionError() def test_angular_convention_without_context(): message = angular.angular_convention('tag', 'message', '') - if not ('tag: message\n'): raise AssertionError() def test_changelog_convention(): message = changelog.changelog_convention('tag', 'message') - if not ('TAG: message\n'): raise AssertionError() def test_symphony_convention(): message = symphony.symphony_convention('tag', 'message') - if not ('[Tag] message\n'): raise AssertionError() def test_no_convention(): inputs = [ - "message", + "message", ] def mock_input(s): return inputs.pop(0) no_convention.input = mock_input - message = no_convention.just_message() if not message == 'Message\n': raise AssertionError() diff --git a/test/test_utils.py b/test/test_utils.py index db6e1ec..61ccfa4 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -10,6 +10,7 @@ def test_get_text(): def mock_input(s): return inputs.pop(0) + utils.input = mock_input a, b = utils.get_text() if not a == 'tag':