From 5fbab74f09f36d0fa8729ce7990131d874c8e7df Mon Sep 17 00:00:00 2001 From: Steve Messick Date: Tue, 23 Jun 2026 22:58:16 +0000 Subject: [PATCH 1/2] Reorganize tests and rename unit_tests.py to backend_tests.py - Moved all tests to a new top-level 'test' directory. - Structured 'test' into 'unit', 'integration', and 'backend' subdirectories. - Renamed 'tests/unit_tests.py' to 'test/backend/backend_tests.py'. - Updated configuration in pyproject.toml and path references in tests. TAG=agy CONV=1e8b909d-d25a-422d-9783-bac0b56fdf9d --- integration_tests/__init__.py | 0 pyproject.toml | 11 +++++------ tests/unit_tests.py => test/backend/backend_tests.py | 6 +++--- {tests => test/backend}/dataset/data.csv | 0 {tests => test/backend}/kernel/testing-x.ipynb | 0 {tests => test/backend}/model/instance/data.csv | 0 .../backend}/model/instance/version/metadata.json | 0 {tests => test/backend}/sample_submission.csv | 0 .../integration}/test_models.py | 0 {tests => test}/run_tests.sh | 4 ++-- {tests => test}/test_commands.sh | 0 {src/kaggle/test => test/unit}/conftest.py | 0 {src/kaggle/test => test/unit}/test_authenticate.py | 0 {src/kaggle/test => test/unit}/test_benchmarks_cli.py | 0 {tests => test/unit}/test_dataset_metadata_update.py | 2 +- {tests => test/unit}/test_dataset_status.py | 2 +- .../kaggle/test => test/unit}/test_discussions_cli.py | 0 {tests => test/unit}/test_kernel_parsing.py | 2 +- {tests => test/unit}/test_kernels_logs.py | 2 +- {tests => test/unit}/test_kernels_pull.py | 2 +- {tests => test/unit}/test_quota.py | 2 +- {tests => test/unit}/test_retry_after.py | 0 {tests => test/unit}/test_team_submissions.py | 2 +- tests/__init__.py | 0 24 files changed, 17 insertions(+), 18 deletions(-) delete mode 100644 integration_tests/__init__.py rename tests/unit_tests.py => test/backend/backend_tests.py (99%) rename {tests => test/backend}/dataset/data.csv (100%) rename {tests => test/backend}/kernel/testing-x.ipynb (100%) rename {tests => test/backend}/model/instance/data.csv (100%) rename {tests => test/backend}/model/instance/version/metadata.json (100%) rename {tests => test/backend}/sample_submission.csv (100%) rename {integration_tests => test/integration}/test_models.py (100%) rename {tests => test}/run_tests.sh (75%) rename {tests => test}/test_commands.sh (100%) rename {src/kaggle/test => test/unit}/conftest.py (100%) rename {src/kaggle/test => test/unit}/test_authenticate.py (100%) rename {src/kaggle/test => test/unit}/test_benchmarks_cli.py (100%) rename {tests => test/unit}/test_dataset_metadata_update.py (99%) rename {tests => test/unit}/test_dataset_status.py (99%) rename {src/kaggle/test => test/unit}/test_discussions_cli.py (100%) rename {tests => test/unit}/test_kernel_parsing.py (98%) rename {tests => test/unit}/test_kernels_logs.py (99%) rename {tests => test/unit}/test_kernels_pull.py (99%) rename {tests => test/unit}/test_quota.py (99%) rename {tests => test/unit}/test_retry_after.py (100%) rename {tests => test/unit}/test_team_submissions.py (99%) delete mode 100644 tests/__init__.py diff --git a/integration_tests/__init__.py b/integration_tests/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/pyproject.toml b/pyproject.toml index 25e0792b..0496437b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,9 +55,9 @@ dependencies = [ ] [tool.hatch.envs.test.scripts] -local = "source tools/use-localhost.sh; cd tests; python unit_tests.py --failfast" -prod = "source tools/use-prod.sh; cd tests; python unit_tests.py --failfast" -integration = "pytest integration_tests" +local = "source tools/use-localhost.sh; cd test/backend; python backend_tests.py --failfast" +prod = "source tools/use-prod.sh; cd test/backend; python backend_tests.py --failfast" +integration = "pytest test/integration" [tool.hatch.envs.lint] detached = true @@ -73,7 +73,7 @@ dependencies = [ ] [tool.hatch.envs.lint.scripts] -typing = "mypy --install-types --non-interactive {args:src/kaggle tests}" +typing = "mypy --install-types --non-interactive {args:src/kaggle test}" style = [ "black --check --diff {args:.}", ] @@ -105,7 +105,6 @@ ignore_missing_imports = true [tool.pytest.ini_options] testpaths = [ - "src/kaggle/test", - "tests", + "test/unit", ] pythonpath = ["src"] diff --git a/tests/unit_tests.py b/test/backend/backend_tests.py similarity index 99% rename from tests/unit_tests.py rename to test/backend/backend_tests.py index 1dcaaac1..056a4626 100644 --- a/tests/unit_tests.py +++ b/test/backend/backend_tests.py @@ -10,7 +10,7 @@ from requests import HTTPError # noinspection PyTypeChecker -sys.path.insert(0, "..") +sys.path.insert(0, "../..") from kaggle import api from kagglesdk.kernels.types.kernels_enums import KernelWorkerStatus @@ -23,8 +23,8 @@ # In the case of unresolvable failure, run reset_database.sh. # To run from Rider, create a Python tests>Unittests run config. -# Give it the module: unit_tests.TestKaggleApi -# Set the working directory to: kaggle-cli/tests +# Give it the module: backend_tests.TestKaggleApi +# Set the working directory to: kaggle-cli/test/backend # Define some envars: # KAGGLE_API_ENVIRONMENT=LOCALHOST # KAGGLE_CONFIG_DIR=/home/kaggle/.config/kaggle/dev diff --git a/tests/dataset/data.csv b/test/backend/dataset/data.csv similarity index 100% rename from tests/dataset/data.csv rename to test/backend/dataset/data.csv diff --git a/tests/kernel/testing-x.ipynb b/test/backend/kernel/testing-x.ipynb similarity index 100% rename from tests/kernel/testing-x.ipynb rename to test/backend/kernel/testing-x.ipynb diff --git a/tests/model/instance/data.csv b/test/backend/model/instance/data.csv similarity index 100% rename from tests/model/instance/data.csv rename to test/backend/model/instance/data.csv diff --git a/tests/model/instance/version/metadata.json b/test/backend/model/instance/version/metadata.json similarity index 100% rename from tests/model/instance/version/metadata.json rename to test/backend/model/instance/version/metadata.json diff --git a/tests/sample_submission.csv b/test/backend/sample_submission.csv similarity index 100% rename from tests/sample_submission.csv rename to test/backend/sample_submission.csv diff --git a/integration_tests/test_models.py b/test/integration/test_models.py similarity index 100% rename from integration_tests/test_models.py rename to test/integration/test_models.py diff --git a/tests/run_tests.sh b/test/run_tests.sh similarity index 75% rename from tests/run_tests.sh rename to test/run_tests.sh index 3f0f57b6..683b4027 100755 --- a/tests/run_tests.sh +++ b/test/run_tests.sh @@ -12,8 +12,8 @@ echo "Running fast unit tests with pytest..." # Run live integration tests only if stdin is a TTY (invoked interactively) if [ -t 0 ]; then - echo "Running live integration tests (unit_tests.py)..." - python3 -m unittest unit_tests.py + echo "Running live integration tests (backend_tests.py)..." + (cd "$SCRIPT_DIR/backend" && python3 -m unittest backend_tests.py) fi echo "All tests passed!" diff --git a/tests/test_commands.sh b/test/test_commands.sh similarity index 100% rename from tests/test_commands.sh rename to test/test_commands.sh diff --git a/src/kaggle/test/conftest.py b/test/unit/conftest.py similarity index 100% rename from src/kaggle/test/conftest.py rename to test/unit/conftest.py diff --git a/src/kaggle/test/test_authenticate.py b/test/unit/test_authenticate.py similarity index 100% rename from src/kaggle/test/test_authenticate.py rename to test/unit/test_authenticate.py diff --git a/src/kaggle/test/test_benchmarks_cli.py b/test/unit/test_benchmarks_cli.py similarity index 100% rename from src/kaggle/test/test_benchmarks_cli.py rename to test/unit/test_benchmarks_cli.py diff --git a/tests/test_dataset_metadata_update.py b/test/unit/test_dataset_metadata_update.py similarity index 99% rename from tests/test_dataset_metadata_update.py rename to test/unit/test_dataset_metadata_update.py index 7d06ebba..b1ae961a 100644 --- a/tests/test_dataset_metadata_update.py +++ b/test/unit/test_dataset_metadata_update.py @@ -8,7 +8,7 @@ # Ensure parent directory is in path for imports import sys -sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))) from kaggle.api.kaggle_api_extended import KaggleApi from kagglesdk.datasets.types.dataset_types import DatasetSettings, DatasetSettingsFile, DatasetSettingsFileColumn diff --git a/tests/test_dataset_status.py b/test/unit/test_dataset_status.py similarity index 99% rename from tests/test_dataset_status.py rename to test/unit/test_dataset_status.py index a535e2f8..b18d9a5b 100644 --- a/tests/test_dataset_status.py +++ b/test/unit/test_dataset_status.py @@ -4,7 +4,7 @@ from unittest.mock import MagicMock, patch import sys -sys.path.insert(0, "..") +sys.path.insert(0, "../..") from kaggle.api.kaggle_api_extended import KaggleApi, _parse_format diff --git a/src/kaggle/test/test_discussions_cli.py b/test/unit/test_discussions_cli.py similarity index 100% rename from src/kaggle/test/test_discussions_cli.py rename to test/unit/test_discussions_cli.py diff --git a/tests/test_kernel_parsing.py b/test/unit/test_kernel_parsing.py similarity index 98% rename from tests/test_kernel_parsing.py rename to test/unit/test_kernel_parsing.py index a6ee3c4e..175eede2 100644 --- a/tests/test_kernel_parsing.py +++ b/test/unit/test_kernel_parsing.py @@ -3,7 +3,7 @@ import unittest from unittest.mock import patch -sys.path.insert(0, "../src") +sys.path.insert(0, "../../src") from kaggle.api.kaggle_api_extended import KaggleApi diff --git a/tests/test_kernels_logs.py b/test/unit/test_kernels_logs.py similarity index 99% rename from tests/test_kernels_logs.py rename to test/unit/test_kernels_logs.py index 74b22cc0..399f341d 100644 --- a/tests/test_kernels_logs.py +++ b/test/unit/test_kernels_logs.py @@ -6,7 +6,7 @@ import tempfile import sys -sys.path.insert(0, "..") +sys.path.insert(0, "../..") from kaggle.api.kaggle_api_extended import KaggleApi diff --git a/tests/test_kernels_pull.py b/test/unit/test_kernels_pull.py similarity index 99% rename from tests/test_kernels_pull.py rename to test/unit/test_kernels_pull.py index 69634b11..54fd3c34 100644 --- a/tests/test_kernels_pull.py +++ b/test/unit/test_kernels_pull.py @@ -5,7 +5,7 @@ import unittest from unittest.mock import patch, MagicMock, mock_open -sys.path.insert(0, "../src") +sys.path.insert(0, "../../src") from kaggle.api.kaggle_api_extended import KaggleApi diff --git a/tests/test_quota.py b/test/unit/test_quota.py similarity index 99% rename from tests/test_quota.py rename to test/unit/test_quota.py index f75be1ef..0567e5fc 100644 --- a/tests/test_quota.py +++ b/test/unit/test_quota.py @@ -5,7 +5,7 @@ from datetime import datetime, timedelta, timezone from unittest.mock import MagicMock, patch -sys.path.insert(0, "..") +sys.path.insert(0, "../..") from kaggle.api.kaggle_api_extended import KaggleApi diff --git a/tests/test_retry_after.py b/test/unit/test_retry_after.py similarity index 100% rename from tests/test_retry_after.py rename to test/unit/test_retry_after.py diff --git a/tests/test_team_submissions.py b/test/unit/test_team_submissions.py similarity index 99% rename from tests/test_team_submissions.py rename to test/unit/test_team_submissions.py index ba1245da..5bea689f 100644 --- a/tests/test_team_submissions.py +++ b/test/unit/test_team_submissions.py @@ -4,7 +4,7 @@ import unittest from unittest.mock import MagicMock, patch -sys.path.insert(0, "..") +sys.path.insert(0, "../..") from kaggle.api.kaggle_api_extended import KaggleApi diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index e69de29b..00000000 From d0cfab6ad8970ae6e3e0cf03200cd083c2d6aa8d Mon Sep 17 00:00:00 2001 From: Steve Messick Date: Wed, 24 Jun 2026 14:30:15 +0000 Subject: [PATCH 2/2] Rename test directory to tests TAG=agy CONV=1e8b909d-d25a-422d-9783-bac0b56fdf9d --- pyproject.toml | 10 +++++----- {test => tests}/backend/backend_tests.py | 2 +- {test => tests}/backend/dataset/data.csv | 0 {test => tests}/backend/kernel/testing-x.ipynb | 0 {test => tests}/backend/model/instance/data.csv | 0 .../backend/model/instance/version/metadata.json | 0 {test => tests}/backend/sample_submission.csv | 0 {test => tests}/integration/test_models.py | 0 {test => tests}/run_tests.sh | 0 {test => tests}/test_commands.sh | 0 {test => tests}/unit/conftest.py | 0 {test => tests}/unit/test_authenticate.py | 0 {test => tests}/unit/test_benchmarks_cli.py | 0 {test => tests}/unit/test_dataset_metadata_update.py | 0 {test => tests}/unit/test_dataset_status.py | 0 {test => tests}/unit/test_discussions_cli.py | 0 {test => tests}/unit/test_kernel_parsing.py | 0 {test => tests}/unit/test_kernels_logs.py | 0 {test => tests}/unit/test_kernels_pull.py | 0 {test => tests}/unit/test_quota.py | 0 {test => tests}/unit/test_retry_after.py | 0 {test => tests}/unit/test_team_submissions.py | 0 22 files changed, 6 insertions(+), 6 deletions(-) rename {test => tests}/backend/backend_tests.py (99%) rename {test => tests}/backend/dataset/data.csv (100%) rename {test => tests}/backend/kernel/testing-x.ipynb (100%) rename {test => tests}/backend/model/instance/data.csv (100%) rename {test => tests}/backend/model/instance/version/metadata.json (100%) rename {test => tests}/backend/sample_submission.csv (100%) rename {test => tests}/integration/test_models.py (100%) rename {test => tests}/run_tests.sh (100%) rename {test => tests}/test_commands.sh (100%) rename {test => tests}/unit/conftest.py (100%) rename {test => tests}/unit/test_authenticate.py (100%) rename {test => tests}/unit/test_benchmarks_cli.py (100%) rename {test => tests}/unit/test_dataset_metadata_update.py (100%) rename {test => tests}/unit/test_dataset_status.py (100%) rename {test => tests}/unit/test_discussions_cli.py (100%) rename {test => tests}/unit/test_kernel_parsing.py (100%) rename {test => tests}/unit/test_kernels_logs.py (100%) rename {test => tests}/unit/test_kernels_pull.py (100%) rename {test => tests}/unit/test_quota.py (100%) rename {test => tests}/unit/test_retry_after.py (100%) rename {test => tests}/unit/test_team_submissions.py (100%) diff --git a/pyproject.toml b/pyproject.toml index 0496437b..c84c3ed6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,9 +55,9 @@ dependencies = [ ] [tool.hatch.envs.test.scripts] -local = "source tools/use-localhost.sh; cd test/backend; python backend_tests.py --failfast" -prod = "source tools/use-prod.sh; cd test/backend; python backend_tests.py --failfast" -integration = "pytest test/integration" +local = "source tools/use-localhost.sh; cd tests/backend; python backend_tests.py --failfast" +prod = "source tools/use-prod.sh; cd tests/backend; python backend_tests.py --failfast" +integration = "pytest tests/integration" [tool.hatch.envs.lint] detached = true @@ -73,7 +73,7 @@ dependencies = [ ] [tool.hatch.envs.lint.scripts] -typing = "mypy --install-types --non-interactive {args:src/kaggle test}" +typing = "mypy --install-types --non-interactive {args:src/kaggle tests}" style = [ "black --check --diff {args:.}", ] @@ -105,6 +105,6 @@ ignore_missing_imports = true [tool.pytest.ini_options] testpaths = [ - "test/unit", + "tests/unit", ] pythonpath = ["src"] diff --git a/test/backend/backend_tests.py b/tests/backend/backend_tests.py similarity index 99% rename from test/backend/backend_tests.py rename to tests/backend/backend_tests.py index 056a4626..88c1c931 100644 --- a/test/backend/backend_tests.py +++ b/tests/backend/backend_tests.py @@ -24,7 +24,7 @@ # To run from Rider, create a Python tests>Unittests run config. # Give it the module: backend_tests.TestKaggleApi -# Set the working directory to: kaggle-cli/test/backend +# Set the working directory to: kaggle-cli/tests/backend # Define some envars: # KAGGLE_API_ENVIRONMENT=LOCALHOST # KAGGLE_CONFIG_DIR=/home/kaggle/.config/kaggle/dev diff --git a/test/backend/dataset/data.csv b/tests/backend/dataset/data.csv similarity index 100% rename from test/backend/dataset/data.csv rename to tests/backend/dataset/data.csv diff --git a/test/backend/kernel/testing-x.ipynb b/tests/backend/kernel/testing-x.ipynb similarity index 100% rename from test/backend/kernel/testing-x.ipynb rename to tests/backend/kernel/testing-x.ipynb diff --git a/test/backend/model/instance/data.csv b/tests/backend/model/instance/data.csv similarity index 100% rename from test/backend/model/instance/data.csv rename to tests/backend/model/instance/data.csv diff --git a/test/backend/model/instance/version/metadata.json b/tests/backend/model/instance/version/metadata.json similarity index 100% rename from test/backend/model/instance/version/metadata.json rename to tests/backend/model/instance/version/metadata.json diff --git a/test/backend/sample_submission.csv b/tests/backend/sample_submission.csv similarity index 100% rename from test/backend/sample_submission.csv rename to tests/backend/sample_submission.csv diff --git a/test/integration/test_models.py b/tests/integration/test_models.py similarity index 100% rename from test/integration/test_models.py rename to tests/integration/test_models.py diff --git a/test/run_tests.sh b/tests/run_tests.sh similarity index 100% rename from test/run_tests.sh rename to tests/run_tests.sh diff --git a/test/test_commands.sh b/tests/test_commands.sh similarity index 100% rename from test/test_commands.sh rename to tests/test_commands.sh diff --git a/test/unit/conftest.py b/tests/unit/conftest.py similarity index 100% rename from test/unit/conftest.py rename to tests/unit/conftest.py diff --git a/test/unit/test_authenticate.py b/tests/unit/test_authenticate.py similarity index 100% rename from test/unit/test_authenticate.py rename to tests/unit/test_authenticate.py diff --git a/test/unit/test_benchmarks_cli.py b/tests/unit/test_benchmarks_cli.py similarity index 100% rename from test/unit/test_benchmarks_cli.py rename to tests/unit/test_benchmarks_cli.py diff --git a/test/unit/test_dataset_metadata_update.py b/tests/unit/test_dataset_metadata_update.py similarity index 100% rename from test/unit/test_dataset_metadata_update.py rename to tests/unit/test_dataset_metadata_update.py diff --git a/test/unit/test_dataset_status.py b/tests/unit/test_dataset_status.py similarity index 100% rename from test/unit/test_dataset_status.py rename to tests/unit/test_dataset_status.py diff --git a/test/unit/test_discussions_cli.py b/tests/unit/test_discussions_cli.py similarity index 100% rename from test/unit/test_discussions_cli.py rename to tests/unit/test_discussions_cli.py diff --git a/test/unit/test_kernel_parsing.py b/tests/unit/test_kernel_parsing.py similarity index 100% rename from test/unit/test_kernel_parsing.py rename to tests/unit/test_kernel_parsing.py diff --git a/test/unit/test_kernels_logs.py b/tests/unit/test_kernels_logs.py similarity index 100% rename from test/unit/test_kernels_logs.py rename to tests/unit/test_kernels_logs.py diff --git a/test/unit/test_kernels_pull.py b/tests/unit/test_kernels_pull.py similarity index 100% rename from test/unit/test_kernels_pull.py rename to tests/unit/test_kernels_pull.py diff --git a/test/unit/test_quota.py b/tests/unit/test_quota.py similarity index 100% rename from test/unit/test_quota.py rename to tests/unit/test_quota.py diff --git a/test/unit/test_retry_after.py b/tests/unit/test_retry_after.py similarity index 100% rename from test/unit/test_retry_after.py rename to tests/unit/test_retry_after.py diff --git a/test/unit/test_team_submissions.py b/tests/unit/test_team_submissions.py similarity index 100% rename from test/unit/test_team_submissions.py rename to tests/unit/test_team_submissions.py