From 04d965a6a5b6deb6a9df6cdacdb9849759e815a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alvaro=20Andr=C3=A9s=20Rodr=C3=ADguez=20Scelza?= Date: Tue, 11 Jun 2019 11:48:44 -0300 Subject: [PATCH] testing for xml encoding checker --- .../general_hooks/check_xml_encoding_test.py | 31 +++++++++++++++++++ .../check_xml_encoding_samples/__init__.py | 0 .../first_line_is_empty_space.xml | 10 ++++++ .../no_encoding.xml | 8 +++++ .../check_xml_encoding_samples/ok.xml | 9 ++++++ 5 files changed, 58 insertions(+) create mode 100644 pre_commit_hooks/loaderon_hooks/tests/automatic_testing/general_hooks/check_xml_encoding_test.py create mode 100644 pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_xml_encoding_samples/__init__.py create mode 100644 pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_xml_encoding_samples/first_line_is_empty_space.xml create mode 100644 pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_xml_encoding_samples/no_encoding.xml create mode 100644 pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_xml_encoding_samples/ok.xml diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/general_hooks/check_xml_encoding_test.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/general_hooks/check_xml_encoding_test.py new file mode 100644 index 0000000..4f785d7 --- /dev/null +++ b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/general_hooks/check_xml_encoding_test.py @@ -0,0 +1,31 @@ +import sys + +import pytest + +from pre_commit_hooks.loaderon_hooks.general_hooks.check_xml_encoding 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 = [] + + # Encoding to be checked + sys.argv.append('--encoding') + sys.argv.append(r'') + yield + + +def test_check_xml_encoding_ok(): + perform_test_on_file_expecting_result('check_xml_encoding_samples/ok.xml', main) + + +def test_check_xml_encoding_error_1(): + perform_test_on_file_expecting_result('check_xml_encoding_samples/no_encoding.xml', main, expected_result=2) + + +def test_check_xml_encoding_error_2(): + perform_test_on_file_expecting_result('check_xml_encoding_samples/first_line_is_empty_space.xml', + main, + expected_result=2) 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_files/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_files/check_xml_encoding_samples/first_line_is_empty_space.xml new file mode 100644 index 0000000..3dfebd8 --- /dev/null +++ b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_xml_encoding_samples/first_line_is_empty_space.xml @@ -0,0 +1,10 @@ + + + + + + some.model.form.inherit + some.model + + + 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_files/check_xml_encoding_samples/no_encoding.xml new file mode 100644 index 0000000..c0b4a2f --- /dev/null +++ b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/testing_files/check_xml_encoding_samples/no_encoding.xml @@ -0,0 +1,8 @@ + + + + some.model.form.inherit + 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_files/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_files/check_xml_encoding_samples/ok.xml @@ -0,0 +1,9 @@ + + + + + some.model.form.inherit + some.model + + +