diff --git a/WorkerThreads/__pycache__/DownloadWorker.cpython-312.pyc b/WorkerThreads/__pycache__/DownloadWorker.cpython-312.pyc new file mode 100644 index 0000000..82a8bac Binary files /dev/null and b/WorkerThreads/__pycache__/DownloadWorker.cpython-312.pyc differ diff --git a/WorkerThreads/__pycache__/IndexerWorker.cpython-312.pyc b/WorkerThreads/__pycache__/IndexerWorker.cpython-312.pyc new file mode 100644 index 0000000..fd00d96 Binary files /dev/null and b/WorkerThreads/__pycache__/IndexerWorker.cpython-312.pyc differ diff --git a/WorkerThreads/__pycache__/TextExtractWorker.cpython-312.pyc b/WorkerThreads/__pycache__/TextExtractWorker.cpython-312.pyc new file mode 100644 index 0000000..83fabc2 Binary files /dev/null and b/WorkerThreads/__pycache__/TextExtractWorker.cpython-312.pyc differ diff --git a/__pycache__/app.cpython-312.pyc b/__pycache__/app.cpython-312.pyc new file mode 100644 index 0000000..18d550b Binary files /dev/null and b/__pycache__/app.cpython-312.pyc differ diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..65e1367 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,14 @@ +[pytest] +testpaths = tests +python_files = test_*.py +python_classes = Test* +python_functions = test_* + +# Add markers and other configurations as needed +markers = + sanity: mark a test as a sanity check + integration: mark integration tests + +# Configure warning suppression if needed +filterwarnings = + ignore::DeprecationWarning \ No newline at end of file diff --git a/tests/__pycache__/test_project_sanity.cpython-312-pytest-8.3.5.pyc b/tests/__pycache__/test_project_sanity.cpython-312-pytest-8.3.5.pyc new file mode 100644 index 0000000..6dbb086 Binary files /dev/null and b/tests/__pycache__/test_project_sanity.cpython-312-pytest-8.3.5.pyc differ diff --git a/tests/test_project_sanity.py b/tests/test_project_sanity.py new file mode 100644 index 0000000..f10658f --- /dev/null +++ b/tests/test_project_sanity.py @@ -0,0 +1,105 @@ +import os +import sys +import importlib +import pytest +import warnings +import importlib.util + +# Add the project root directory to the Python path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) + +def mock_missing_module(module_name): + """ + Create a mock module to replace missing optional dependencies. + """ + spec = importlib.util.spec_from_loader(module_name, loader=None) + module = importlib.util.module_from_spec(spec) + return module + +def test_worker_threads_importable(): + """ + Verify that worker thread modules can be imported, with some allowance for optional dependencies. + """ + worker_thread_modules = [ + 'WorkerThreads.DownloadWorker', + 'WorkerThreads.IndexerWorker', + 'WorkerThreads.TextExtractWorker' + ] + + failures = [] + for module_name in worker_thread_modules: + try: + module = importlib.import_module(module_name) + # More flexible module structure check + if module_name == 'WorkerThreads.IndexerWorker': + # Skip strict class check for IndexerWorker + continue + except ImportError as e: + # For TextExtractWorker, which might have optional dependencies + if module_name == 'WorkerThreads.TextExtractWorker': + warnings.warn(f"Optional module {module_name} not fully importable: {e}", ImportWarning) + else: + failures.append(f"Failed to import module {module_name}: {e}") + + assert len(failures) == 0, f"Import failures:\n" + "\n".join(failures) + +def test_authentication_files_exist(): + """ + Check that required authentication configuration files exist. + """ + auth_files = [ + '.auth/client_id.json', + '.auth/credentials.json' + ] + + for file_path in auth_files: + assert os.path.exists(file_path), f"Authentication file {file_path} is missing" + +def test_app_py_exists(): + """ + Verify that the main application file exists. + """ + assert os.path.exists('app.py'), "Main application file 'app.py' is missing" + +def test_requirements_file_exists(): + """ + Check that the requirements file exists. + """ + assert os.path.exists('requirements.txt'), "Requirements file is missing" + +def test_app_py_importable(): + """ + Verify that the main application can be imported with some tolerance for missing optional dependencies. + """ + try: + # Mock optional dependencies + optional_modules = ['textract', 'apiclient'] + for module_name in optional_modules: + if module_name not in sys.modules: + sys.modules[module_name] = mock_missing_module(module_name) + + # Suppress warnings about optional dependencies + with warnings.catch_warnings(): + warnings.simplefilter("ignore", ImportWarning) + module = importlib.import_module('app') + except ImportError as e: + pytest.fail(f"Failed to import main application: {e}") + finally: + # Remove mock modules + for module_name in optional_modules: + if module_name in sys.modules and isinstance(sys.modules[module_name], type(mock_missing_module(module_name))): + del sys.modules[module_name] + +def test_critical_project_files_exist(): + """ + Comprehensive check for critical project files. + """ + critical_files = [ + 'README.md', + '.gitignore', + 'app.py', + 'requirements.txt' + ] + + for file_path in critical_files: + assert os.path.exists(file_path), f"Critical file {file_path} is missing" \ No newline at end of file