diff --git a/.coveragerc b/.coveragerc index a7e2dfd..9458a0e 100644 --- a/.coveragerc +++ b/.coveragerc @@ -6,7 +6,7 @@ omit = .tox/* /usr/* setup.py - pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/* + pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/* [report] show_missing = True diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/general_hooks/check_using_pylint_test.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/general_hooks/check_using_pylint_test.py index cd66d5f..dcb00ba 100644 --- a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/general_hooks/check_using_pylint_test.py +++ b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/general_hooks/check_using_pylint_test.py @@ -32,7 +32,7 @@ def test_with_pylint_error(): def walk_return(folder_path): - root = '/home/administrador/Escritorio/pre-commit-hooks/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_using_pylint_samples' + root = '/home/administrador/Escritorio/pre-commit-hooks/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_using_pylint_samples' unused_dirs = [] files = ['.pylintrc'] return [(root, unused_dirs, files)] diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/odoo_specific_hooks/check_model_name_test.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/odoo_specific_hooks/check_model_name_test.py new file mode 100644 index 0000000..14d1e57 --- /dev/null +++ b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/odoo_specific_hooks/check_model_name_test.py @@ -0,0 +1,25 @@ +import sys + +import pytest + +from pre_commit_hooks.loaderon_hooks.odoo_specific_hooks.check_model_name import main +from pre_commit_hooks.loaderon_hooks.tests.automatic_testing.util.test_helpers import \ + perform_test_on_file_expecting_result + + +@pytest.fixture(autouse=True) +def clean_sys_argv(): + sys.argv = [] + yield + + +def test_check_model_name_ok(): + perform_test_on_file_expecting_result('check_model_name_samples/ok.py', main) + + +def test_check_model_name_multiple_inheritance_ok(): + perform_test_on_file_expecting_result('check_model_name_samples/multiple_inheritance_ok.py', main) + + +def test_check_model_name_error(): + perform_test_on_file_expecting_result('check_model_name_samples/error.py', main, expected_result=2) diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/odoo_specific_hooks/check_view_fields_order_test.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/odoo_specific_hooks/check_view_fields_order_test.py new file mode 100644 index 0000000..b468859 --- /dev/null +++ b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/odoo_specific_hooks/check_view_fields_order_test.py @@ -0,0 +1,25 @@ +import sys + +import pytest + +from pre_commit_hooks.loaderon_hooks.odoo_specific_hooks.check_view_fields_order import main +from pre_commit_hooks.loaderon_hooks.tests.automatic_testing.util.test_helpers import \ + perform_test_on_file_expecting_result + + +@pytest.fixture(autouse=True) +def clean_sys_argv(): + sys.argv = [] + yield + + +def test_check_view_fields_order_ok(): + perform_test_on_file_expecting_result('check_view_fields_order_samples/ok.xml', main) + + +def test_check_view_fields_order_name_error(): + perform_test_on_file_expecting_result('check_view_fields_order_samples/first_field_not_name_error.xml', main, expected_result=2) + + +def test_check_view_fields_order_model_error(): + perform_test_on_file_expecting_result('check_view_fields_order_samples/second_field_not_model_error.xml', main, expected_result=2) diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/__init__.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/__init__.py similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/__init__.py rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/__init__.py diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_class_docstring_samples/__init__.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_class_docstring_samples/__init__.py similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_class_docstring_samples/__init__.py rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_class_docstring_samples/__init__.py diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_class_docstring_samples/docstring_error_1.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_class_docstring_samples/docstring_error_1.py similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_class_docstring_samples/docstring_error_1.py rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_class_docstring_samples/docstring_error_1.py diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_class_docstring_samples/docstring_error_2.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_class_docstring_samples/docstring_error_2.py similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_class_docstring_samples/docstring_error_2.py rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_class_docstring_samples/docstring_error_2.py diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_class_docstring_samples/docstring_error_3.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_class_docstring_samples/docstring_error_3.py similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_class_docstring_samples/docstring_error_3.py rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_class_docstring_samples/docstring_error_3.py diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_class_docstring_samples/docstring_error_4.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_class_docstring_samples/docstring_error_4.py similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_class_docstring_samples/docstring_error_4.py rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_class_docstring_samples/docstring_error_4.py diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_class_docstring_samples/docstring_error_5.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_class_docstring_samples/docstring_error_5.py similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_class_docstring_samples/docstring_error_5.py rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_class_docstring_samples/docstring_error_5.py diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_class_docstring_samples/docstring_error_6.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_class_docstring_samples/docstring_error_6.py similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_class_docstring_samples/docstring_error_6.py rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_class_docstring_samples/docstring_error_6.py diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_class_docstring_samples/docstring_error_7.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_class_docstring_samples/docstring_error_7.py similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_class_docstring_samples/docstring_error_7.py rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_class_docstring_samples/docstring_error_7.py diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_class_docstring_samples/docstring_ok.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_class_docstring_samples/docstring_ok.py similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_class_docstring_samples/docstring_ok.py rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_class_docstring_samples/docstring_ok.py diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_line_samples/__init__.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_line_samples/__init__.py similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_line_samples/__init__.py rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_line_samples/__init__.py diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_line_samples/xml_lines_error_1.xml b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_line_samples/xml_lines_error_1.xml similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_line_samples/xml_lines_error_1.xml rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_line_samples/xml_lines_error_1.xml diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_line_samples/xml_lines_ok.xml b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_line_samples/xml_lines_ok.xml similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_line_samples/xml_lines_ok.xml rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_line_samples/xml_lines_ok.xml diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_location_samples/__init__.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_location_samples/__init__.py similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_location_samples/__init__.py rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_location_samples/__init__.py diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_location_samples/javascript/correct_js.js b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_location_samples/javascript/correct_js.js similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_location_samples/javascript/correct_js.js rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_location_samples/javascript/correct_js.js diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_location_samples/not_enabled_directory/incorrect_xml.xml b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_location_samples/not_enabled_directory/incorrect_xml.xml similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_location_samples/not_enabled_directory/incorrect_xml.xml rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_location_samples/not_enabled_directory/incorrect_xml.xml diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_location_samples/xml/correct_xml.xml b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_location_samples/xml/correct_xml.xml similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_location_samples/xml/correct_xml.xml rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_location_samples/xml/correct_xml.xml diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_location_samples/xml/incorrect_js.js b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_location_samples/xml/incorrect_js.js similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_location_samples/xml/incorrect_js.js rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_location_samples/xml/incorrect_js.js diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_using_pylint_samples/__init__.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_model_name_samples/__init__.py similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_using_pylint_samples/__init__.py rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_model_name_samples/__init__.py diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_model_name_samples/error.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_model_name_samples/error.py new file mode 100644 index 0000000..f7099e5 --- /dev/null +++ b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_model_name_samples/error.py @@ -0,0 +1,2 @@ +class SomeClass(object): + _name = "some.model.name" diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_model_name_samples/multiple_inheritance_ok.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_model_name_samples/multiple_inheritance_ok.py new file mode 100644 index 0000000..e4a76f0 --- /dev/null +++ b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_model_name_samples/multiple_inheritance_ok.py @@ -0,0 +1,2 @@ +class SomeClass(object): + _inherit = ['some_model_name', 'some_other_model_name'] diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_model_name_samples/ok.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_model_name_samples/ok.py new file mode 100644 index 0000000..8fd6299 --- /dev/null +++ b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_model_name_samples/ok.py @@ -0,0 +1,2 @@ +class SomeClass(object): + _name = "testing_files.some.model.name" diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_using_pylint_samples/.pylintrc b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_using_pylint_samples/.pylintrc similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_using_pylint_samples/.pylintrc rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_using_pylint_samples/.pylintrc diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_xml_encoding_samples/__init__.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_using_pylint_samples/__init__.py similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_xml_encoding_samples/__init__.py rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_using_pylint_samples/__init__.py diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_using_pylint_samples/correct.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_using_pylint_samples/correct.py similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_using_pylint_samples/correct.py rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_using_pylint_samples/correct.py diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_using_pylint_samples/incorrect.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_using_pylint_samples/incorrect.py similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_using_pylint_samples/incorrect.py rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_using_pylint_samples/incorrect.py diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_using_pylint_samples/incorrect_but_ignored.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_using_pylint_samples/incorrect_but_ignored.py similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_using_pylint_samples/incorrect_but_ignored.py rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_using_pylint_samples/incorrect_but_ignored.py diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_view_fields_order_samples/__init__.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_view_fields_order_samples/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_view_fields_order_samples/first_field_not_name_error.xml b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_view_fields_order_samples/first_field_not_name_error.xml new file mode 100644 index 0000000..bec43f3 --- /dev/null +++ b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_view_fields_order_samples/first_field_not_name_error.xml @@ -0,0 +1,9 @@ + + + + + Jhon Doe + some.model + + + diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_xml_encoding_samples/ok.xml b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_view_fields_order_samples/ok.xml similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_xml_encoding_samples/ok.xml rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_view_fields_order_samples/ok.xml diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_view_fields_order_samples/second_field_not_model_error.xml b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_view_fields_order_samples/second_field_not_model_error.xml new file mode 100644 index 0000000..9199808 --- /dev/null +++ b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_view_fields_order_samples/second_field_not_model_error.xml @@ -0,0 +1,9 @@ + + + + + some.model.form.inherit + Jhon Doe + + + diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_xml_encoding_samples/__init__.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_xml_encoding_samples/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_xml_encoding_samples/first_line_is_empty_space.xml b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_xml_encoding_samples/first_line_is_empty_space.xml similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_xml_encoding_samples/first_line_is_empty_space.xml rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_xml_encoding_samples/first_line_is_empty_space.xml diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_xml_encoding_samples/no_encoding.xml b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_xml_encoding_samples/no_encoding.xml similarity index 100% rename from pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_xml_encoding_samples/no_encoding.xml rename to pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_xml_encoding_samples/no_encoding.xml diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_xml_encoding_samples/ok.xml b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_xml_encoding_samples/ok.xml new file mode 100644 index 0000000..3b054a5 --- /dev/null +++ b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_samples/check_xml_encoding_samples/ok.xml @@ -0,0 +1,9 @@ + + + + + some.model.form.inherit + some.model + + + diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/util/test_helpers.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/util/test_helpers.py index 3107e89..b776841 100644 --- a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/util/test_helpers.py +++ b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/util/test_helpers.py @@ -4,7 +4,7 @@ import sys def get_sample_file_path(file_name): current_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - testing_files_folder_path = current_path + '/testing_files/' + testing_files_folder_path = current_path + '/testing_samples/' return testing_files_folder_path + file_name