From e2b773eac5a7a2344df54118fefaaa428f70d925 Mon Sep 17 00:00:00 2001 From: KnugiHK <24708955+KnugiHK@users.noreply.github.com> Date: Wed, 7 May 2025 21:31:29 +0800 Subject: [PATCH] Move all tests to single directory --- tests/__init__.py | 0 tests/data/contacts.vcf | 5 +++++ .../test_brazilian_number_processing.py | 4 ++-- .../vcards_contacts_test.py => tests/test_vcards_contacts.py | 4 +++- 4 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 tests/__init__.py create mode 100644 tests/data/contacts.vcf rename scripts/brazilian_number_processing_test.py => tests/test_brazilian_number_processing.py (98%) rename Whatsapp_Chat_Exporter/vcards_contacts_test.py => tests/test_vcards_contacts.py (79%) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/data/contacts.vcf b/tests/data/contacts.vcf new file mode 100644 index 0000000..12a026b --- /dev/null +++ b/tests/data/contacts.vcf @@ -0,0 +1,5 @@ +BEGIN:VCARD +VERSION:3.0 +FN:Sample Contact +TEL;TYPE=CELL:+85288888888 +END:VCARD \ No newline at end of file diff --git a/scripts/brazilian_number_processing_test.py b/tests/test_brazilian_number_processing.py similarity index 98% rename from scripts/brazilian_number_processing_test.py rename to tests/test_brazilian_number_processing.py index 8c6a38b..f7ccd27 100644 --- a/scripts/brazilian_number_processing_test.py +++ b/tests/test_brazilian_number_processing.py @@ -4,7 +4,7 @@ import tempfile import os from unittest.mock import patch -from brazilian_number_processing import process_phone_number, process_vcard +from scripts.brazilian_number_processing import process_phone_number, process_vcard class TestVCardProcessor(unittest.TestCase): @@ -248,7 +248,7 @@ END:VCARD output_path = input_path + '.out' try: - test_args = ['python' if os.name == 'nt' else 'python3', 'brazilian_number_processing.py', input_path, output_path] + test_args = ['python' if os.name == 'nt' else 'python3', 'scripts/brazilian_number_processing.py', input_path, output_path] # We're just testing that the argument parsing works subprocess.call( test_args, diff --git a/Whatsapp_Chat_Exporter/vcards_contacts_test.py b/tests/test_vcards_contacts.py similarity index 79% rename from Whatsapp_Chat_Exporter/vcards_contacts_test.py rename to tests/test_vcards_contacts.py index 194b637..5d22b56 100644 --- a/Whatsapp_Chat_Exporter/vcards_contacts_test.py +++ b/tests/test_vcards_contacts.py @@ -1,10 +1,12 @@ # from contacts_names_from_vcards import readVCardsFile +import os from Whatsapp_Chat_Exporter.vcards_contacts import normalize_number, read_vcards_file def test_readVCardsFile(): - assert len(read_vcards_file("contacts.vcf", "973")) > 0 + data_dir = os.path.join(os.path.dirname(__file__), "data") + assert len(read_vcards_file(os.path.join(data_dir, "contacts.vcf"), "852")) > 0 def test_create_number_to_name_dicts(): pass