be consistent with env var names
This commit is contained in:
parent
6fd3b598ab
commit
d8f2e03d36
3 changed files with 34 additions and 5 deletions
|
|
@ -24,7 +24,7 @@ uv sync --all-groups
|
|||
uv run repub
|
||||
```
|
||||
|
||||
By default the UI listens on `127.0.0.1:8080`. You can override that with `REPUB_HOST` and `REPUB_PORT`, or with:
|
||||
By default the UI listens on `127.0.0.1:8080`. You can override that with `REPUBLISHER_HOST` and `REPUBLISHER_PORT`, or with:
|
||||
|
||||
```sh
|
||||
uv run repub serve --host 0.0.0.0 --port 8080
|
||||
|
|
|
|||
|
|
@ -34,12 +34,12 @@ def parse_args(argv: list[str] | None = None) -> tuple[str, argparse.Namespace]:
|
|||
serve_parser = subparsers.add_parser("serve", help="Start the republisher web UI")
|
||||
serve_parser.add_argument(
|
||||
"--host",
|
||||
default=os.environ.get("REPUB_HOST", "127.0.0.1"),
|
||||
default=os.environ.get("REPUBLISHER_HOST", "127.0.0.1"),
|
||||
help="Host interface for the web UI",
|
||||
)
|
||||
serve_parser.add_argument(
|
||||
"--port",
|
||||
default=os.environ.get("REPUB_PORT", "8080"),
|
||||
default=os.environ.get("REPUBLISHER_PORT", "8080"),
|
||||
help="Port for the web UI",
|
||||
)
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ def entrypoint(argv: list[str] | None = None) -> int:
|
|||
try:
|
||||
port = int(args.port)
|
||||
except ValueError:
|
||||
logger.error("Invalid REPUB_PORT/--port value: %s", args.port)
|
||||
logger.error("Invalid REPUBLISHER_PORT/--port value: %s", args.port)
|
||||
return 2
|
||||
|
||||
app = create_app()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import io
|
||||
from types import SimpleNamespace
|
||||
|
||||
from repub.entrypoint import FeedNameFilter
|
||||
from repub.entrypoint import FeedNameFilter, entrypoint, logger, parse_args
|
||||
|
||||
|
||||
def test_feed_name_filter_accepts_matching_item() -> None:
|
||||
|
|
@ -15,3 +16,31 @@ def test_feed_name_filter_rejects_non_matching_item() -> None:
|
|||
feed_filter = FeedNameFilter({"feed_name": "nasa"})
|
||||
|
||||
assert feed_filter.accepts(item) is False
|
||||
|
||||
|
||||
def test_parse_args_uses_republisher_host_and_port_env_vars(monkeypatch) -> None:
|
||||
monkeypatch.setenv("REPUBLISHER_HOST", "0.0.0.0")
|
||||
monkeypatch.setenv("REPUBLISHER_PORT", "9090")
|
||||
|
||||
command, args = parse_args(["serve"])
|
||||
|
||||
assert command == "serve"
|
||||
assert args.host == "0.0.0.0"
|
||||
assert args.port == "9090"
|
||||
|
||||
|
||||
def test_entrypoint_rejects_invalid_republisher_port(monkeypatch) -> None:
|
||||
monkeypatch.setenv("REPUBLISHER_PORT", "not-a-number")
|
||||
stream = io.StringIO()
|
||||
original_streams = [handler.stream for handler in logger.handlers]
|
||||
for handler in logger.handlers:
|
||||
handler.stream = stream
|
||||
|
||||
try:
|
||||
exit_code = entrypoint(["serve"])
|
||||
finally:
|
||||
for handler, original_stream in zip(logger.handlers, original_streams):
|
||||
handler.stream = original_stream
|
||||
|
||||
assert exit_code == 2
|
||||
assert "Invalid REPUBLISHER_PORT/--port value" in stream.getvalue()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue