diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/general_hooks/__init__.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/general_hooks/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/general_hooks/check_class_docstring_test.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/general_hooks/check_class_docstring_test.py new file mode 100644 index 0000000..1fb89db --- /dev/null +++ b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/general_hooks/check_class_docstring_test.py @@ -0,0 +1,37 @@ +import subprocess +import sys +import uuid + +import pytest + +from pre_commit_hooks.loaderon_hooks.general_hooks.check_branch_name import main + + +@pytest.fixture(autouse=True) +def clean_sys_argv(): + sys.argv = [] + yield + + +def test_branch_name_ok(): + new_branch_name = str(uuid.uuid4()) + subprocess.check_output(['git', 'checkout', '-b', new_branch_name]) + sys.argv.append('--regex') + sys.argv.append(r'\b(?!master)\b\S+') + + result = main(sys.argv) + + subprocess.check_output(['git', 'checkout', 'master']) + subprocess.check_output(['git', 'branch', '-d', new_branch_name]) + + assert result == 0 + + +def test_branch_name_error(): + subprocess.check_output(['git', 'checkout', 'master']) + sys.argv.append('--regex') + sys.argv.append(r'\b(?!master)\b\S+') + + result = main(sys.argv) + + assert result == 2 diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/odoo_specific_hooks/__init__.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/odoo_specific_hooks/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/docstring_samples.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/docstring_samples.py new file mode 100644 index 0000000..20a8c61 --- /dev/null +++ b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/docstring_samples.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- + + +class TestingClass(object): # SHOULD FAIL + pass + + +class TestingClass2(object): # SHOULD PASS + """""" + + +class TestingClass3(object): # SHOULD PASS + """ + Hola mundo + """ + + +class TestingClass4(object): # SHOULD FAIL + "" + + +class TestingClass5(object): # SHOULD FAIL + def foo(self): + pass + + +class TestingClass6(object): # SHOULD FAIL + def foo(self): + pass + + """Hola mundo""" + + +class TestingClass7(object): # SHOULD FAIL + + """Hola mundo""" + + +class TestingClass8(object): # SHOULD PASS + """Hola mundo""" + + +class TestingClass9(object): # SHOULD FAIL + class TestingClass10(object): + """Hola mundo""" + + +class TestingClass11(object): # SHOULD PASS + """Hola mundo""" + class TestingClass12(object): + """Hola mundo"""