Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

2.3 KB
Raw Blame
"""Unit tests for som package (Set-of-Mark).

This file tests ONLY basic som functionality.
Following SRP: This file tests som module imports and basic operations.
All external dependencies (ML models, OCR) are mocked.
"""

import pytest


class TestSomImports:
    """Test som module imports (SRP: Only tests imports)."""

    def test_som_module_exists(self):
        """Test that som module can be imported."""
        try:
            import som

            assert som is not None
        except ImportError:
            pytest.skip("som module not installed")

    def test_omniparser_import(self):
        """Test that OmniParser can be imported."""
        try:
            from som import OmniParser

            assert OmniParser is not None
        except ImportError:
            pytest.skip("som module not available")
        except Exception as e:
            pytest.skip(f"som initialization requires ML models: {e}")

    def test_models_import(self):
        """Test that model classes can be imported."""
        try:
            from som import BoundingBox, ParseResult, UIElement

            assert BoundingBox is not None
            assert UIElement is not None
            assert ParseResult is not None
        except ImportError:
            pytest.skip("som models not available")
        except Exception as e:
            pytest.skip(f"som models require dependencies: {e}")


class TestSomModels:
    """Test som data models (SRP: Only tests model structure)."""

    def test_bounding_box_structure(self):
        """Test BoundingBox class structure."""
        try:
            from som import BoundingBox

            # Check the class exists and has expected structure
            assert hasattr(BoundingBox, "__init__")
        except ImportError:
            pytest.skip("som models not available")
        except Exception as e:
            pytest.skip(f"som models require dependencies: {e}")

    def test_ui_element_structure(self):
        """Test UIElement class structure."""
        try:
            from som import UIElement

            # Check the class exists and has expected structure
            assert hasattr(UIElement, "__init__")
        except ImportError:
            pytest.skip("som models not available")
        except Exception as e:
            pytest.skip(f"som models require dependencies: {e}")