Skip to content

Commit b490cb1

Browse files
authored
Merge pull request #4 from bsgip/cactusschema
Migrated to cactus-schema
2 parents 5e31e22 + ec4a3df commit b490cb1

11 files changed

Lines changed: 23 additions & 105 deletions

File tree

.github/workflows/linttest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959

6060
- name: Install Dependencies
6161
run: |
62-
pip install .[server,dev]
62+
pip install .[dev]
6363
6464
- name: Run mypy
6565
run: mypy .
@@ -82,7 +82,7 @@ jobs:
8282

8383
- name: Install Dependencies
8484
run: |
85-
pip install .[server,test]
85+
pip install .[test]
8686
8787
- name: Run Pytest
8888
run: pytest

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN apt-get update; apt-get install -y git openssh-client
88
RUN git config --global url."https://git@github.com/".insteadOf "ssh://git@github.com/"
99

1010
# Install app / dependencies
11-
RUN pip install --no-cache-dir "cactus-client-notifications[server] @ git+ssh://git@github.com/bsgip/cactus-client-notifications.git@${CACTUS_CLIENT_NOTIFICATIONS_VERSION}" gunicorn
11+
RUN pip install --no-cache-dir "cactus-client-notifications @ git+ssh://git@github.com/bsgip/cactus-client-notifications.git@${CACTUS_CLIENT_NOTIFICATIONS_VERSION}" gunicorn
1212

1313
# RUN stage
1414
FROM python:3.12-slim

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ Any mutual TLS / other considerations are expected to be managed at the point of
1111

1212
## Development
1313

14-
`pip install cactus_client_notifications` will install ONLY the schema dependencies (the default)
14+
`pip install cactus_client_notifications` will install all dependencies for running the server
1515

16-
`pip install cactus_client_notifications[server]` will also install the dependencies for running the server (use for deployments)
17-
18-
`pip install cactus_client_notifications[server,dev,test]` will install ALL dependencies for development / tests
16+
`pip install cactus_client_notifications[dev,test]` will install ALL dependencies for development / tests
1917

2018
## Configuration
2119

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,13 @@ build-backend = "setuptools.build_meta"
4242
[project]
4343
name = "cactus_client_notifications"
4444
dynamic = ["version", "readme"]
45-
description = "Schema and mini webserver for accepting CSIP-Aus subscription notifications via dynamic webhook URIs."
45+
description = "Mini webserver for accepting CSIP-Aus subscription notifications via dynamic webhook URIs."
4646
dependencies = [
47-
"dataclass-wizard>=0.35.0,<1",
48-
47+
"cactus-schema>=0.0.4,<1",
48+
"aiohttp>=3.11.12,<4",
4949
] # These dependencies are purely for the schema (the default reference). Server dependencies require "server"
5050

5151
[project.optional-dependencies]
52-
server = ["aiohttp>=3.11.12,<4"]
5352
dev = ["bandit", "black", "coverage", "flake8", "flake8-bugbear", "mypy"]
5453
test = ["assertical", "pytest", "pytest-asyncio", "pytest-aiohttp", "freezegun"]
5554

src/cactus_client_notifications/schema/__init__.py

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/cactus_client_notifications/server/endpoint_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from typing import Any
99

1010
from aiohttp import web
11+
from cactus_schema.notification import CollectedHeader, CollectedNotification
1112

12-
from cactus_client_notifications.schema import CollectedHeader, CollectedNotification
1313
from cactus_client_notifications.server.time import utc_now
1414

1515
logger = logging.getLogger(__name__)

src/cactus_client_notifications/server/handler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
from importlib.metadata import version
44

55
from aiohttp import ContentTypeError, web
6-
7-
from cactus_client_notifications.schema import (
8-
URI_ENDPOINT,
6+
from cactus_schema.notification import (
97
CollectEndpointResponse,
108
ConfigureEndpointRequest,
119
CreateEndpointResponse,
10+
uri,
1211
)
12+
1313
from cactus_client_notifications.server.endpoint_store import (
1414
NotificationException,
1515
generate_collected_notification,
@@ -62,7 +62,7 @@ def path_join(*parts: str) -> str:
6262
def generate_public_uri(server_settings: ServerSettings, endpoint_id: str) -> str:
6363
"""Generates the public facing URI for a specific endpoint_id"""
6464
return path_join(
65-
server_settings.public_server_url, server_settings.mount_point, URI_ENDPOINT.format(endpoint_id=endpoint_id)
65+
server_settings.public_server_url, server_settings.mount_point, uri.URI_ENDPOINT.format(endpoint_id=endpoint_id)
6666
)
6767

6868

src/cactus_client_notifications/server/main.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from typing import AsyncGenerator
88

99
from aiohttp import web
10+
from cactus_schema.notification import uri
1011

11-
import cactus_client_notifications.schema as schema
1212
import cactus_client_notifications.server.shared as shared
1313
from cactus_client_notifications.server import handler
1414
from cactus_client_notifications.server.endpoint_store import EndpointStore
@@ -91,13 +91,13 @@ def create_app() -> web.Application:
9191
# Add routes for Test Runner
9292
mount = server_settings.mount_point
9393
app.router.add_route(
94-
"POST", handler.path_join(mount, schema.URI_MANAGE_ENDPOINT_LIST), handler.post_manage_endpoint_list
94+
"POST", handler.path_join(mount, uri.URI_MANAGE_ENDPOINT_LIST), handler.post_manage_endpoint_list
9595
)
96-
app.router.add_route("GET", handler.path_join(mount, schema.URI_MANAGE_ENDPOINT), handler.get_manage_endpoint)
97-
app.router.add_route("PUT", handler.path_join(mount, schema.URI_MANAGE_ENDPOINT), handler.put_manage_endpoint)
98-
app.router.add_route("DELETE", handler.path_join(mount, schema.URI_MANAGE_ENDPOINT), handler.delete_manage_endpoint)
99-
app.router.add_route("*", handler.path_join(mount, schema.URI_ENDPOINT), handler.webhook_endpoint)
100-
app.router.add_route("GET", handler.path_join(mount, schema.URI_MANAGE_SERVER), handler.get_manage_server)
96+
app.router.add_route("GET", handler.path_join(mount, uri.URI_MANAGE_ENDPOINT), handler.get_manage_endpoint)
97+
app.router.add_route("PUT", handler.path_join(mount, uri.URI_MANAGE_ENDPOINT), handler.put_manage_endpoint)
98+
app.router.add_route("DELETE", handler.path_join(mount, uri.URI_MANAGE_ENDPOINT), handler.delete_manage_endpoint)
99+
app.router.add_route("*", handler.path_join(mount, uri.URI_ENDPOINT), handler.webhook_endpoint)
100+
app.router.add_route("GET", handler.path_join(mount, uri.URI_MANAGE_SERVER), handler.get_manage_server)
101101

102102
# Start the periodic task
103103
app.cleanup_ctx.append(setup_periodic_task)

tests/integration/test_endpoints.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
import pytest
55
from aiohttp import ClientSession
6-
7-
from cactus_client_notifications.schema import (
6+
from cactus_schema.notification import (
87
CollectEndpointResponse,
98
ConfigureEndpointRequest,
109
CreateEndpointResponse,

tests/unit/schema/test_models.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
import cactus_schema.notification as schema
12
import pytest
23
from assertical.asserts.generator import assert_class_instance_equality
34
from assertical.fake.generator import generate_class_instance
45
from dataclass_wizard import JSONWizard
56

6-
import cactus_client_notifications.schema as schema
7-
87

98
@pytest.mark.parametrize(
109
"type",

0 commit comments

Comments
 (0)