diff --git a/.github/workflows/schedule.yml b/.github/workflows/schedule.yml index 905c811..4a03029 100644 --- a/.github/workflows/schedule.yml +++ b/.github/workflows/schedule.yml @@ -32,6 +32,8 @@ jobs: python -m pip install --upgrade pip pip install -r requirements.txt - name: Run unit tests + env: + USER_DATA: "[]" run: python -m unittest discover -s tests -v - name: Test Douyin accessibility run: | diff --git a/DouYinSparkFlow/core/tasks.py b/DouYinSparkFlow/core/tasks.py index d310a38..bf19271 100644 --- a/DouYinSparkFlow/core/tasks.py +++ b/DouYinSparkFlow/core/tasks.py @@ -20,8 +20,6 @@ from utils.config import get_config, get_userData, normalize_unique_id, save_use from utils.logger import setup_logger -config = get_config() -user_data = get_userData() logger = setup_logger(level=logging.DEBUG) debug_artifacts_dir = Path("logs/debug_artifacts") debug_artifacts_dir.mkdir(parents=True, exist_ok=True) diff --git a/DouYinSparkFlow/tests/test_config_contract.py b/DouYinSparkFlow/tests/test_config_contract.py index 42cad1e..0b2361c 100644 --- a/DouYinSparkFlow/tests/test_config_contract.py +++ b/DouYinSparkFlow/tests/test_config_contract.py @@ -1,5 +1,7 @@ import json import os +import subprocess +import sys import tempfile import unittest from pathlib import Path @@ -27,6 +29,21 @@ class ConfigContractTests(unittest.TestCase): self.assertFalse(loaded["useProtocolSender"]) self.assertTrue(loaded["persistentBrowserProfiles"]["enabled"]) + def test_tasks_import_does_not_require_runtime_user_data(self): + source_root = Path(__file__).resolve().parents[1] + env = os.environ.copy() + env["GITHUB_ACTIONS"] = "true" + env.pop("USER_DATA", None) + result = subprocess.run( + [sys.executable, "-c", "import core.tasks"], + cwd=source_root, + env=env, + capture_output=True, + text=True, + timeout=30, + ) + self.assertEqual(0, result.returncode, result.stderr) + def test_profile_root_environment_override_wins(self): with patch.dict(os.environ, {"SPARKFLOW_BROWSER_PROFILE_ROOT": "/tmp/sparkflow-profiles"}): normalized = tasks._normalize_persistent_profile_config(config_module.DEFAULT_CONFIG) diff --git a/DouYinSparkFlow/tests/test_deployment_contract.py b/DouYinSparkFlow/tests/test_deployment_contract.py index 7531cca..25e327b 100644 --- a/DouYinSparkFlow/tests/test_deployment_contract.py +++ b/DouYinSparkFlow/tests/test_deployment_contract.py @@ -15,6 +15,7 @@ class DeploymentContractTests(unittest.TestCase): self.assertIn("working-directory: DouYinSparkFlow", text) self.assertIn("SPARKFLOW_BROWSER_PROFILE_ROOT", text) self.assertIn("SPARKFLOW_MANUAL_RUN", text) + self.assertIn('USER_DATA: "[]"', text) self.assertIn("path: DouYinSparkFlow/logs/", text) def test_github_actions_are_pinned_to_commit_shas(self):