Skip to content

Python tool for aircraft Doppler audio geolocation using historical ADS-B flight data (Source-available)

1.3 KB
Raw Blame
import sys

import pytest

from dopplergeist.cli import main


@pytest.mark.parametrize(
    ("option", "value", "message"),
    [
        ("--max-upload-mb", "0", "Value must be a positive integer"),
        ("--max-upload-mb", "-1", "Value must be a positive integer"),
        ("--port", "-1", "Port must be between 0 and 65535"),
        ("--port", "65536", "Port must be between 0 and 65535"),
    ],
)
def test_serve_rejects_invalid_limits_before_startup(monkeypatch, capsys, tmp_path, option, value, message):
    jobs = tmp_path / "jobs"
    monkeypatch.setattr(sys, "argv", ["dopplergeist", "serve", "--jobs", str(jobs), option, value])

    with pytest.raises(SystemExit) as error:
        main()

    assert error.value.code == 2
    assert message in capsys.readouterr().err
    assert not jobs.exists()


@pytest.mark.parametrize("value", ["0", "-1"])
def test_analyze_rejects_nonpositive_upload_limit_before_startup(monkeypatch, capsys, tmp_path, value):
    jobs = tmp_path / "jobs"
    monkeypatch.setattr(sys, "argv", ["dopplergeist", "analyze", "not-needed.mp3", "--jobs", str(jobs),
                                    "--max-upload-mb", value])
    with pytest.raises(SystemExit) as error:
        main()
    assert error.value.code == 2
    assert "Value must be a positive integer" in capsys.readouterr().err
    assert not jobs.exists()