Beispiel #1
0
def test_checkdispatchpython_inaccessible_dispatch(tmp_path):
    """The charm has a dispatch we can't use."""
    dispatch = tmp_path / "dispatch"
    dispatch.touch()
    dispatch.chmod(0o000)
    result = check_dispatch_with_python_entrypoint(tmp_path)
    assert result is None
Beispiel #2
0
def test_checkdispatchpython_entrypoint_no_exec(tmp_path):
    """The charm entrypoint is not executable."""
    dispatch = tmp_path / "dispatch"
    dispatch.write_text(EXAMPLE_DISPATCH)
    entrypoint = tmp_path / "charm.py"
    entrypoint.touch()
    result = check_dispatch_with_python_entrypoint(tmp_path)
    assert result is None
Beispiel #3
0
def test_checkdispatchpython_python(tmp_path):
    """The charm is written in Python."""
    dispatch = tmp_path / "dispatch"
    dispatch.write_text(EXAMPLE_DISPATCH)
    entrypoint = tmp_path / "charm.py"
    entrypoint.touch()
    entrypoint.chmod(0o700)
    result = check_dispatch_with_python_entrypoint(tmp_path)
    assert result == entrypoint
Beispiel #4
0
def test_checkdispatchpython_entrypoint_is_not_python(tmp_path):
    """The charm entrypoint has not a .py extension."""
    dispatch = tmp_path / "dispatch"
    dispatch.write_text("""
        #!/bin/sh
        ./charm
    """)
    entrypoint = tmp_path / "charm.py"
    entrypoint.touch()
    entrypoint.chmod(0o700)
    result = check_dispatch_with_python_entrypoint(tmp_path)
    assert result is None
Beispiel #5
0
def test_checkdispatchpython_no_entrypoint(tmp_path):
    """Cannot find the entrypoint used in dispatch."""
    dispatch = tmp_path / "dispatch"
    dispatch.write_text(EXAMPLE_DISPATCH)
    result = check_dispatch_with_python_entrypoint(tmp_path)
    assert result is None
Beispiel #6
0
def test_checkdispatchpython_empty_dispatch(tmp_path):
    """The charm dispatch is empty."""
    dispatch = tmp_path / "dispatch"
    dispatch.write_text("")
    result = check_dispatch_with_python_entrypoint(tmp_path)
    assert result is None
Beispiel #7
0
def test_checkdispatchpython_broken_dispatch(tmp_path):
    """The charm has a dispatch which we can't decode."""
    dispatch = tmp_path / "dispatch"
    dispatch.write_bytes(b"\xC0\xC0")
    result = check_dispatch_with_python_entrypoint(tmp_path)
    assert result is None
Beispiel #8
0
def test_checkdispatchpython_no_dispatch(tmp_path):
    """The charm has no dispatch at all."""
    result = check_dispatch_with_python_entrypoint(tmp_path)
    assert result is None