"""Test extension deployer."""


from apiposture_pro.deployment.deployer import ExtensionDeployer


def test_is_deployed_initially() -> None:
    """Test extension is not deployed initially."""
    deployer = ExtensionDeployer()
    assert not deployer.is_deployed()


def test_deploy_extension() -> None:
    """Test deploying extension."""
    deployer = ExtensionDeployer()

    # Should have found package path
    assert deployer.package_path is not None

    deployer.deploy()
    assert deployer.is_deployed()

    # Check directory structure
    ext_path = deployer.EXTENSION_DIR / "apiposture_pro"
    assert ext_path.exists()
    assert (ext_path / "__init__.py").exists()


def test_undeploy_extension() -> None:
    """Test undeploying extension."""
    deployer = ExtensionDeployer()
    deployer.deploy()

    assert deployer.is_deployed()

    deployer.undeploy()
    assert not deployer.is_deployed()


def test_redeploy_extension() -> None:
    """Test redeploying extension."""
    deployer = ExtensionDeployer()

    deployer.deploy()
    assert deployer.is_deployed()

    # Redeploy should work
    deployer.deploy()
    assert deployer.is_deployed()
