Skip to content

Add new instructions API #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.3.1
current_version = 1.4.0
commit = False
tag = False

Expand Down
10 changes: 9 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# syntax=docker/dockerfile:1.1.7-experimental

#############################################
# Tox testsuite for multiple python version #
#############################################
Expand All @@ -20,6 +21,7 @@ RUN export RESOLVED_VERSIONS=`pyenv_resolve $PYTHON_VERSIONS` \
# Base builder image #
######################
FROM python:3.11-bookworm as builder_base
ARG RUNE_TAG="v1.0.6"

ENV \
# locale
Expand Down Expand Up @@ -71,6 +73,10 @@ RUN --mount=type=ssh pip3 install wheel virtualenv \
&& pip3 install --no-deps --find-links=/tmp/wheelhouse/ /tmp/wheelhouse/*.whl \
&& true

# Add rune instructions
RUN mkdir -p /opt/templates \
&& curl -L https://github.com/pvarki/rune-fake-metadata/releases/download/${RUNE_TAG}/rune.json -o /opt/templates/rune-fake.json \
&& ls -lah /opt/templates/rune-fake.json

####################################
# Base stage for production builds #
Expand Down Expand Up @@ -98,6 +104,7 @@ COPY --from=production_build /tmp/wheelhouse /tmp/wheelhouse
COPY --from=production_build /docker-entrypoint.sh /docker-entrypoint.sh
COPY --from=production_build /container-init.sh /container-init.sh
COPY --from=pvarki/kw_product_init:latest /kw_product_init /kw_product_init
COPY --from=builder_base /opt/templates/rune-fake.json /opt/templates/rune-fake.json

WORKDIR /app
# Install system level deps for running the package (not devel versions for building wheels)
Expand Down Expand Up @@ -127,13 +134,14 @@ ENTRYPOINT ["/usr/bin/tini", "--", "/docker-entrypoint.sh"]
# Base stage for development builds #
#####################################
FROM builder_base as devel_build
COPY --from=builder_base /opt/templates/rune-fake.json /opt/templates/rune-fake.json

# Install deps
WORKDIR /pysetup
RUN --mount=type=ssh source /.venv/bin/activate \
&& poetry install --no-interaction --no-ansi \
&& true


#0############
# Run tests #
#############
Expand Down
2,916 changes: 1,609 additions & 1,307 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "rmfpapi"
version = "1.3.1"
version = "1.4.0"
description = "Fake product RASENMAEHER integration API service"
authors = ["Eero af Heurlin <eero.afheurlin@iki.fi>"]
homepage = "https://github.com/pvarki/python-rasenmaeher-rmfpapi/"
Expand Down
2 changes: 1 addition & 1 deletion src/rmfpapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
""" Fake product RASENMAEHER integration API service """
__version__ = "1.3.1" # NOTE Use `bump2version --config-file patch` to bump versions correctly
__version__ = "1.4.0" # NOTE Use `bump2version --config-file patch` to bump versions correctly
14 changes: 8 additions & 6 deletions src/rmfpapi/api/instructions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Instructions endpoints"""
from typing import Dict
import logging
import json
from pathlib import Path

from fastapi import APIRouter, Depends
from libpvarki.middleware import MTLSHeader
Expand All @@ -12,10 +14,10 @@


@router.post("/{language}")
async def user_intructions(user: UserCRUDRequest) -> Dict[str, str]:
async def user_intructions(user: UserCRUDRequest, language: str) -> Dict[str, str]:
"""return user instructions"""
return {
"callsign": user.callsign,
"instructions": "FIXME: Return something sane",
"language": "en",
}
instructions_json_file = Path("/opt/templates/rune-fake.json")

tak_instructions_data = json.loads(instructions_json_file.read_text(encoding="utf-8"))

return {"callsign": user.callsign, "instructions": json.dumps(tak_instructions_data), "language": language}
2 changes: 1 addition & 1 deletion tests/test_rmfpapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def test_version() -> None:
"""Make sure version matches expected"""
assert __version__ == "1.3.1"
assert __version__ == "1.4.0"


def test_healthcheck(mtlsclient: TestClient) -> None:
Expand Down