Platform Compatibility Tests

Tests to verify the package works across different platforms (Colab, Deepnote, Local)

Core Import Tests

def test_core_imports():
    """Test that all core modules can be imported"""
    assert True
def test_version():
    """Test that version is set correctly"""
    assert __version__ is not None
    assert isinstance(__version__, str)
    assert len(__version__) > 0

Environment Detection Tests

def test_environment_detection():
    """Test that environment detection works"""
    env = load_env()
    assert env in ["colab", "dotenv", "external"]

Dependency Checks

def test_core_dependencies():
    """Test that core helper dependencies are available"""
    required_packages = [
        'fastcore',
        'nbformat',
        'dotenv',  # python-dotenv imports as dotenv
        'httpx',
        'spacy',
        'IPython',  # pulled in transitively via dialoghelper
    ]
    
    for package in required_packages:
        spec = importlib.util.find_spec(package)
        assert spec is not None, f"Required package '{package}' not found"
def test_optional_notebook_dependencies():
    """Test if optional notebook dependencies are available (non-critical)"""
    optional_packages = ['pandas', 'numpy', 'matplotlib', 'nltk']
    available = {}
    
    for package in optional_packages:
        spec = importlib.util.find_spec(package)
        available[package] = spec is not None
    
    # Just log availability, don't fail
    print(f"Optional notebook package availability: {available}")
    assert True  # Always pass

Platform-Specific Tests

def test_python_version():
    """Test that Python version meets minimum requirements"""
    assert sys.version_info >= (3, 11), f"Python 3.11+ required, found {sys.version_info}"
def test_spacy_helper():
    """Test spaCy helper functions (without downloading models)"""
    # This should not fail even if no models installed
    models = list_installed_models()
    assert isinstance(models, list)

Integration Test

def test_full_platform_compatibility():
    """Run all platform compatibility tests"""
    print("Testing core imports...")
    test_core_imports()
    
    print("Testing version...")
    test_version()
    
    print("Testing environment detection...")
    test_environment_detection()
    
    print("Testing core dependencies...")
    test_core_dependencies()
    
    print("Checking optional notebook dependencies...")
    test_optional_notebook_dependencies()
    
    print("Testing Python version...")
    test_python_version()
    
    print("Testing spaCy helper...")
    test_spacy_helper()
    
    print("\n✅ All platform compatibility tests passed!")
# Run tests when notebook is executed
if __name__ == "__main__":
    test_full_platform_compatibility()
Testing core imports...
Testing version...
Testing environment detection...
Testing core dependencies...
Checking optional NLP dependencies...
NLP package availability: {'spacy': True, 'nltk': True}
Testing Python version...
Testing spaCy helper...

✅ All platform compatibility tests passed!