Skip to content

Commit 2cf7191

Browse files
authored
Fix endpoint (#41)
## Why is this change necessary? The graphql endpoint was being obscured by the static file mount ## How does this change address the issue? Rearranges the ordering of path definitions ## What side effects does this change have? None ## How is this change tested? unit test and live in downstream repo
1 parent 7e26715 commit 2cf7191

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

.copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier
2-
_commit: v0.0.49
2+
_commit: v0.0.53
33
_src_path: gh:LabAutomationAndScreening/copier-base-template.git
44
description: A web app that is hosted within a local intranet. Nuxt frontend, python
55
backend, docker-compose

template/{% if has_backend %}backend{% endif %}/src/backend_api/app_def.py.jinja

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ def shutdown() -> ShutdownResponse:
6464
return ShutdownResponse()
6565

6666

67-
app.mount(
68-
"/", StaticFiles(directory=STATIC_DIR, html=True), name="static"
69-
) # this needs to go after any defined routes so that the routes take precedence
7067
try:
7168
app.add_middleware(
7269
CORSMiddleware,
@@ -77,6 +74,9 @@ try:
7774
){% endraw %}{% if backend_uses_graphql %}{% raw %}
7875
graphql_app = GraphQLRouter(schema)
7976
app.include_router(graphql_app, prefix="/api/graphql"){% endraw %}{% endif %}{% raw %}
77+
app.mount(
78+
"/", StaticFiles(directory=STATIC_DIR, html=True), name="static"
79+
) # this needs to go after any defined routes so that the routes take precedence
8080
except ( # pragma: no cover # This is just logging unexpected errors, and it's very challenging to explicitly unit test
8181
Exception
8282
):

template/{% if has_backend %}backend{% endif %}/tests/unit/test_healthcheck.py renamed to template/{% if has_backend %}backend{% endif %}/tests/unit/test_healthcheck.py.jinja

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import time
1+
{% raw %}import time
22

33
from backend_api import app_def
44
from backend_api.app_def import app
@@ -27,7 +27,16 @@ def test_When_swagger_route_called__Then_rendered():
2727
response = client.get("/api-docs")
2828

2929
assert response.status_code == codes.OK
30-
assert "Swagger UI" in response.text
30+
assert "Swagger UI" in response.text{% endraw %}{% if backend_uses_graphql %}{% raw %}
31+
32+
33+
def test_When_graphql_route_called__Then_rendered():
34+
client = TestClient(app)
35+
36+
response = client.get("/api/graphql")
37+
38+
assert response.status_code == codes.OK
39+
assert "graphiql" in response.text{% endraw %}{% endif %}{% raw %}
3140

3241

3342
def test_When_shutdown_route_called__Then_system_exit(mocker: MockerFixture):
@@ -42,4 +51,4 @@ def test_When_shutdown_route_called__Then_system_exit(mocker: MockerFixture):
4251
if mocked_os_exit.call_count > 0:
4352
break
4453
time.sleep(0.001)
45-
mocked_os_exit.assert_called_once_with(0)
54+
mocked_os_exit.assert_called_once_with(0){% endraw %}

0 commit comments

Comments
 (0)