|
| 1 | +#!/usr/bin/env python3 |
| 2 | +""" |
| 3 | +Framework Smoke Tests |
| 4 | +===================== |
| 5 | +
|
| 6 | +Basic smoke tests to verify framework imports and basic functionality work in DRY_RUN mode. |
| 7 | +These tests are designed to run quickly and provide early feedback. |
| 8 | +""" |
| 9 | + |
| 10 | +import os |
| 11 | +import importlib |
| 12 | +import pytest |
| 13 | + |
| 14 | +# Set DRY_RUN mode for safe imports |
| 15 | +os.environ.setdefault("STILLME_DRY_RUN", "1") |
| 16 | + |
| 17 | + |
| 18 | +def test_framework_smoke(): |
| 19 | + """Test that framework can be imported and has basic attributes""" |
| 20 | + framework_modules = [ |
| 21 | + "framework", |
| 22 | + "stillme.framework", |
| 23 | + "stillme_core.framework" |
| 24 | + ] |
| 25 | + |
| 26 | + fw = None |
| 27 | + for module_name in framework_modules: |
| 28 | + try: |
| 29 | + fw = importlib.import_module(module_name) |
| 30 | + break |
| 31 | + except (ImportError, ModuleNotFoundError): |
| 32 | + continue |
| 33 | + |
| 34 | + if fw is None: |
| 35 | + pytest.skip("No framework module found - skipping framework smoke test") |
| 36 | + return |
| 37 | + |
| 38 | + # Test basic framework attributes |
| 39 | + assert hasattr(fw, "initialize") or hasattr(fw, "get_agentdev") or hasattr(fw, "StillMeFramework"), \ |
| 40 | + f"Framework module {fw.__name__} missing expected attributes" |
| 41 | + |
| 42 | + |
| 43 | +def test_framework_initialization_smoke(): |
| 44 | + """Test that framework can be initialized in DRY_RUN mode""" |
| 45 | + try: |
| 46 | + from stillme_core.framework import StillMeFramework |
| 47 | + # Should be able to create instance in DRY_RUN mode |
| 48 | + fw = StillMeFramework() |
| 49 | + assert fw is not None |
| 50 | + except ImportError: |
| 51 | + pytest.skip("StillMeFramework not available") |
| 52 | + except Exception as e: |
| 53 | + # In DRY_RUN mode, API key errors are expected and acceptable |
| 54 | + error_msg = str(e).lower() |
| 55 | + if "api" in error_msg and "key" in error_msg: |
| 56 | + pytest.skip("API key required - expected in DRY_RUN mode") |
| 57 | + # Should not fail due to network calls in DRY_RUN |
| 58 | + assert "network" not in error_msg |
| 59 | + |
| 60 | + |
| 61 | +def test_agentdev_integration_smoke(): |
| 62 | + """Test that AgentDev can be accessed through framework""" |
| 63 | + try: |
| 64 | + from stillme_core.framework import StillMeFramework |
| 65 | + fw = StillMeFramework() |
| 66 | + |
| 67 | + # Test AgentDev access |
| 68 | + agentdev = fw.get_agentdev() |
| 69 | + # AgentDev should be available (even if None in some cases) |
| 70 | + assert agentdev is not None or True # Allow None for now |
| 71 | + |
| 72 | + except ImportError: |
| 73 | + pytest.skip("Framework or AgentDev not available") |
| 74 | + except Exception as e: |
| 75 | + # In DRY_RUN mode, API key errors are expected and acceptable |
| 76 | + error_msg = str(e).lower() |
| 77 | + if "api" in error_msg and "key" in error_msg: |
| 78 | + pytest.skip("API key required - expected in DRY_RUN mode") |
| 79 | + # Should not fail due to network calls in DRY_RUN |
| 80 | + assert "network" not in error_msg |
| 81 | + |
| 82 | + |
| 83 | +@pytest.mark.smoke |
| 84 | +def test_framework_dry_run_safe(): |
| 85 | + """Test that framework is safe in DRY_RUN mode""" |
| 86 | + # Ensure DRY_RUN is set |
| 87 | + assert os.environ.get("STILLME_DRY_RUN") == "1" |
| 88 | + |
| 89 | + try: |
| 90 | + from stillme_core.framework import StillMeFramework |
| 91 | + fw = StillMeFramework() |
| 92 | + # Should not make external calls in DRY_RUN mode |
| 93 | + assert True |
| 94 | + except Exception as e: |
| 95 | + # In DRY_RUN mode, API key errors are expected and acceptable |
| 96 | + error_msg = str(e).lower() |
| 97 | + if "api" in error_msg and "key" in error_msg: |
| 98 | + pytest.skip("API key required - expected in DRY_RUN mode") |
| 99 | + # If it fails, it should be a safe failure (no network calls) |
| 100 | + assert "network" not in error_msg |
0 commit comments