Skip to content

Commit

Permalink
Two InterNetNews servers: Austin and Boston (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss authored Oct 22, 2024
1 parent 9b3fd35 commit 6d5b044
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
11 changes: 9 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
services:
internetnews-server:
internetnews-server-austin:
image: cclauss/inn
ports:
- 119:119
- 563:563

internetnews-server-boston:
image: cclauss/inn
ports:
- 1119:119
- 1563:563

fastapi-server:
image: fastapi
build:
Expand All @@ -15,7 +21,8 @@ services:
ports:
- 5001:5001
depends_on:
- internetnews-server
- internetnews-server-austin
- internetnews-server-boston

imls-react:
image: imlsreact
Expand Down
6 changes: 4 additions & 2 deletions server/ome_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from server.schemas import Card, Channel, ChannelSummary, Metadata, NewCard

AUSTIN_PORT = 119
BOSTON_PORT = AUSTIN_PORT + 1000
DEFAULT_NEWSGROUPS: dict[str, str] = {
("control.cancel", "Cancel messages (no posting)"),
("control.checkgroups", "Hierarchy check control messages (no posting)"),
Expand All @@ -20,9 +22,9 @@
CLIENT: nntp.NNTPClient | None = None


def get_client() -> nntp.NNTPClient:
def get_client(port: int = 119) -> nntp.NNTPClient:
global CLIENT # noqa: PLW0603
CLIENT = CLIENT or nntp.NNTPClient("localhost")
CLIENT = CLIENT or nntp.NNTPClient("localhost", port=port)
return CLIENT


Expand Down
8 changes: 6 additions & 2 deletions tests/test_ome_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@

from server import ome_node

AUSTIN_PORT = 119
BOSTON_PORT = AUSTIN_PORT + 1000

def test_nntp_client() -> None:
nntp_client = ome_node.get_client()

@pytest.mark.parametrize("port", [AUSTIN_PORT, BOSTON_PORT])
def test_nntp_client(port: int) -> None:
nntp_client = ome_node.get_client(port=port)
assert isinstance(nntp_client, ome_node.nntp.NNTPClient)
newsgroups = set(nntp_client.list_newsgroups())
assert newsgroups == ome_node.DEFAULT_NEWSGROUPS
Expand Down

0 comments on commit 6d5b044

Please sign in to comment.