Skip to content

Commit

Permalink
Refactor test app
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Aug 20, 2024
1 parent 3b9c2d2 commit 88de58f
Show file tree
Hide file tree
Showing 48 changed files with 41 additions and 33 deletions.
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM ghcr.io/nationalarchives/tna-python:latest

COPY --chown=app . .

RUN tna-build

CMD ["tna-run", "test:app"]
5 changes: 2 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
services:
app:
build:
dockerfile: test/Dockerfile
context: .
environment:
- ENVIRONMENT=develop
- CONFIG=config.Develop
- SECRET_KEY=abc123
ports:
- 5001:8080
volumes:
- ./test:/app
- ./tna_frontend_jinja:/home/app/tna_frontend_jinja
- ./:/app
dev:
image: ghcr.io/nationalarchives/tna-python-dev:preview
volumes:
Expand Down
2 changes: 1 addition & 1 deletion test/poetry.lock → poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions test/pyproject.toml → pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "tna-frontend-jinja-test"
version = "0.1.0"
name = "tna-frontend-jinja"
version = "0.2.8"
description = ""
authors = ["Andrew Hosgood <[email protected]>"]
license = "MIT"
Expand All @@ -12,8 +12,17 @@ Flask = "^3.0.3"
Flask-WTF = "^1.2.1"
deepmerge = "^1.1.1"
markupsafe = "^2.1.5"

[tool.poetry.group.dev]
optional = true

[tool.poetry.group.dev.dependencies]
email-validator = "^2.2.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.black]
line-length = 80
include = '\.pyi?$'
8 changes: 0 additions & 8 deletions test/Dockerfile

This file was deleted.

18 changes: 10 additions & 8 deletions test/app/__init__.py → test/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import os
import sys

from flask import Flask
from jinja2 import ChoiceLoader, PackageLoader, PrefixLoader
from tna_frontend_jinja.wtforms.widgets import WTFormsHelpers

from .components import bp as components_bp
from .forms import bp as forms_bp
# from .forms.routes import WTFormsHelpers
from .templates import bp as templates_bp
from .utilities import bp as utilities_bp


sys.path.append('/home/app/')

from tna_frontend_jinja.wtforms.widgets import WTFormsHelpers

app = Flask(__name__, template_folder="/home/app/tna_frontend_jinja/templates")
app = Flask(__name__)

app.config["SECRET_KEY"] = os.environ.get("SECRET_KEY")

app.jinja_loader = ChoiceLoader(
[
PackageLoader("test"),
PackageLoader("tna_frontend_jinja"),
]
)


@app.route("/healthcheck/live/")
def healthcheck():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

bp = Blueprint("components", __name__, template_folder="test-templates")

from app.components import routes # noqa: E402,F401
from test.components import routes # noqa: E402,F401
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from test.components import bp

from app.components import bp
from flask import render_template, request


Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/app/forms/__init__.py → test/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

bp = Blueprint("forms", __name__, template_folder="test-templates")

from app.forms import routes # noqa: E402,F401
from test.forms import routes # noqa: E402,F401
7 changes: 3 additions & 4 deletions test/app/forms/routes.py → test/forms/routes.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import sys
from app.forms import bp
from test.forms import bp

from flask import redirect, render_template, url_for
from flask_wtf import FlaskForm
from tna_frontend_jinja.wtforms.widgets import GovSubmitInput, GovTextInput
from wtforms import StringField, SubmitField
from wtforms.validators import Email, InputRequired, Length

sys.path.append('/home/app/')
from tna_frontend_jinja.wtforms.widgets import GovTextInput, GovSubmitInput


class ExampleForm(FlaskForm):
email_address = StringField(
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

bp = Blueprint("templates", __name__, template_folder="../templates")

from app.templates import routes # noqa: E402,F401
from test.templates import routes # noqa: E402,F401
2 changes: 1 addition & 1 deletion test/app/templates/routes.py → test/templates/routes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from test.templates import bp

from app.templates import bp
from flask import render_template, request


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

bp = Blueprint("utilities", __name__, template_folder="test-templates")

from app.utilities import routes # noqa: E402,F401
from test.utilities import routes # noqa: E402,F401
2 changes: 1 addition & 1 deletion test/app/utilities/routes.py → test/utilities/routes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from test.utilities import bp

from app.utilities import bp
from flask import render_template, request


Expand Down
File renamed without changes.

0 comments on commit 88de58f

Please sign in to comment.