diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4d2fd4b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM ghcr.io/nationalarchives/tna-python:latest + +COPY --chown=app . . + +RUN tna-build + +CMD ["tna-run", "test:app"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 1ae6d07..1aeaf21 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ services: app: build: - dockerfile: test/Dockerfile + context: . environment: - ENVIRONMENT=develop - CONFIG=config.Develop @@ -9,8 +9,7 @@ services: 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: diff --git a/test/poetry.lock b/poetry.lock similarity index 99% rename from test/poetry.lock rename to poetry.lock index 8a647d1..7fb9383 100644 --- a/test/poetry.lock +++ b/poetry.lock @@ -268,4 +268,4 @@ email = ["email-validator"] [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "11646ef68f626ee8f6dfe173efbc2f50369dad8127093fa34b78c6814f1d0c97" +content-hash = "b3ac598faa362fec49505b7aec125835874cd522c01cd1f304b1bd4b0d8dd6e3" diff --git a/test/pyproject.toml b/pyproject.toml similarity index 68% rename from test/pyproject.toml rename to pyproject.toml index e2e7a18..a78dcdc 100644 --- a/test/pyproject.toml +++ b/pyproject.toml @@ -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 "] license = "MIT" @@ -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?$' \ No newline at end of file diff --git a/test/Dockerfile b/test/Dockerfile deleted file mode 100644 index c11d1d1..0000000 --- a/test/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM ghcr.io/nationalarchives/tna-python:latest - -COPY --chown=app test . -COPY --chown=app ../tna_frontend_jinja /home/app/tna_frontend_jinja - -RUN tna-build - -CMD ["tna-run", "app:app"] \ No newline at end of file diff --git a/test/app/__init__.py b/test/__init__.py similarity index 76% rename from test/app/__init__.py rename to test/__init__.py index ebf4050..ddcd5ac 100644 --- a/test/app/__init__.py +++ b/test/__init__.py @@ -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(): diff --git a/test/app/components/__init__.py b/test/components/__init__.py similarity index 65% rename from test/app/components/__init__.py rename to test/components/__init__.py index 247a085..23ba395 100644 --- a/test/app/components/__init__.py +++ b/test/components/__init__.py @@ -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 diff --git a/test/app/components/routes.py b/test/components/routes.py similarity index 99% rename from test/app/components/routes.py rename to test/components/routes.py index ad439d3..f1c0091 100644 --- a/test/app/components/routes.py +++ b/test/components/routes.py @@ -1,6 +1,6 @@ import json +from test.components import bp -from app.components import bp from flask import render_template, request diff --git a/test/app/components/test-templates/accordion.html b/test/components/test-templates/accordion.html similarity index 100% rename from test/app/components/test-templates/accordion.html rename to test/components/test-templates/accordion.html diff --git a/test/app/components/test-templates/breadcrumbs.html b/test/components/test-templates/breadcrumbs.html similarity index 100% rename from test/app/components/test-templates/breadcrumbs.html rename to test/components/test-templates/breadcrumbs.html diff --git a/test/app/components/test-templates/button.html b/test/components/test-templates/button.html similarity index 100% rename from test/app/components/test-templates/button.html rename to test/components/test-templates/button.html diff --git a/test/app/components/test-templates/card.html b/test/components/test-templates/card.html similarity index 100% rename from test/app/components/test-templates/card.html rename to test/components/test-templates/card.html diff --git a/test/app/components/test-templates/checkboxes.html b/test/components/test-templates/checkboxes.html similarity index 100% rename from test/app/components/test-templates/checkboxes.html rename to test/components/test-templates/checkboxes.html diff --git a/test/app/components/test-templates/compound-filters.html b/test/components/test-templates/compound-filters.html similarity index 100% rename from test/app/components/test-templates/compound-filters.html rename to test/components/test-templates/compound-filters.html diff --git a/test/app/components/test-templates/cookie-banner.html b/test/components/test-templates/cookie-banner.html similarity index 100% rename from test/app/components/test-templates/cookie-banner.html rename to test/components/test-templates/cookie-banner.html diff --git a/test/app/components/test-templates/date-input.html b/test/components/test-templates/date-input.html similarity index 100% rename from test/app/components/test-templates/date-input.html rename to test/components/test-templates/date-input.html diff --git a/test/app/components/test-templates/date-search.html b/test/components/test-templates/date-search.html similarity index 100% rename from test/app/components/test-templates/date-search.html rename to test/components/test-templates/date-search.html diff --git a/test/app/components/test-templates/details.html b/test/components/test-templates/details.html similarity index 100% rename from test/app/components/test-templates/details.html rename to test/components/test-templates/details.html diff --git a/test/app/components/test-templates/error-summary.html b/test/components/test-templates/error-summary.html similarity index 100% rename from test/app/components/test-templates/error-summary.html rename to test/components/test-templates/error-summary.html diff --git a/test/app/components/test-templates/files-list.html b/test/components/test-templates/files-list.html similarity index 100% rename from test/app/components/test-templates/files-list.html rename to test/components/test-templates/files-list.html diff --git a/test/app/components/test-templates/footer.html b/test/components/test-templates/footer.html similarity index 100% rename from test/app/components/test-templates/footer.html rename to test/components/test-templates/footer.html diff --git a/test/app/components/test-templates/gallery.html b/test/components/test-templates/gallery.html similarity index 100% rename from test/app/components/test-templates/gallery.html rename to test/components/test-templates/gallery.html diff --git a/test/app/components/test-templates/global-header.html b/test/components/test-templates/global-header.html similarity index 100% rename from test/app/components/test-templates/global-header.html rename to test/components/test-templates/global-header.html diff --git a/test/app/components/test-templates/header.html b/test/components/test-templates/header.html similarity index 100% rename from test/app/components/test-templates/header.html rename to test/components/test-templates/header.html diff --git a/test/app/components/test-templates/hero.html b/test/components/test-templates/hero.html similarity index 100% rename from test/app/components/test-templates/hero.html rename to test/components/test-templates/hero.html diff --git a/test/app/components/test-templates/index-grid.html b/test/components/test-templates/index-grid.html similarity index 100% rename from test/app/components/test-templates/index-grid.html rename to test/components/test-templates/index-grid.html diff --git a/test/app/components/test-templates/pagination.html b/test/components/test-templates/pagination.html similarity index 100% rename from test/app/components/test-templates/pagination.html rename to test/components/test-templates/pagination.html diff --git a/test/app/components/test-templates/phase-banner.html b/test/components/test-templates/phase-banner.html similarity index 100% rename from test/app/components/test-templates/phase-banner.html rename to test/components/test-templates/phase-banner.html diff --git a/test/app/components/test-templates/picture.html b/test/components/test-templates/picture.html similarity index 100% rename from test/app/components/test-templates/picture.html rename to test/components/test-templates/picture.html diff --git a/test/app/components/test-templates/quick-filters.html b/test/components/test-templates/quick-filters.html similarity index 100% rename from test/app/components/test-templates/quick-filters.html rename to test/components/test-templates/quick-filters.html diff --git a/test/app/components/test-templates/radios.html b/test/components/test-templates/radios.html similarity index 100% rename from test/app/components/test-templates/radios.html rename to test/components/test-templates/radios.html diff --git a/test/app/components/test-templates/records-list.html b/test/components/test-templates/records-list.html similarity index 100% rename from test/app/components/test-templates/records-list.html rename to test/components/test-templates/records-list.html diff --git a/test/app/components/test-templates/search-field.html b/test/components/test-templates/search-field.html similarity index 100% rename from test/app/components/test-templates/search-field.html rename to test/components/test-templates/search-field.html diff --git a/test/app/components/test-templates/select.html b/test/components/test-templates/select.html similarity index 100% rename from test/app/components/test-templates/select.html rename to test/components/test-templates/select.html diff --git a/test/app/components/test-templates/sidebar.html b/test/components/test-templates/sidebar.html similarity index 100% rename from test/app/components/test-templates/sidebar.html rename to test/components/test-templates/sidebar.html diff --git a/test/app/components/test-templates/skip-link.html b/test/components/test-templates/skip-link.html similarity index 100% rename from test/app/components/test-templates/skip-link.html rename to test/components/test-templates/skip-link.html diff --git a/test/app/components/test-templates/tabs.html b/test/components/test-templates/tabs.html similarity index 100% rename from test/app/components/test-templates/tabs.html rename to test/components/test-templates/tabs.html diff --git a/test/app/components/test-templates/text-input.html b/test/components/test-templates/text-input.html similarity index 100% rename from test/app/components/test-templates/text-input.html rename to test/components/test-templates/text-input.html diff --git a/test/app/components/test-templates/textarea.html b/test/components/test-templates/textarea.html similarity index 100% rename from test/app/components/test-templates/textarea.html rename to test/components/test-templates/textarea.html diff --git a/test/app/components/test-templates/warning.html b/test/components/test-templates/warning.html similarity index 100% rename from test/app/components/test-templates/warning.html rename to test/components/test-templates/warning.html diff --git a/test/app/forms/__init__.py b/test/forms/__init__.py similarity index 66% rename from test/app/forms/__init__.py rename to test/forms/__init__.py index 85a449d..2732def 100644 --- a/test/app/forms/__init__.py +++ b/test/forms/__init__.py @@ -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 diff --git a/test/app/forms/routes.py b/test/forms/routes.py similarity index 88% rename from test/app/forms/routes.py rename to test/forms/routes.py index d24286c..189685d 100644 --- a/test/app/forms/routes.py +++ b/test/forms/routes.py @@ -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( diff --git a/test/app/forms/test-templates/example-form.html b/test/forms/test-templates/example-form.html similarity index 100% rename from test/app/forms/test-templates/example-form.html rename to test/forms/test-templates/example-form.html diff --git a/test/app/templates/__init__.py b/test/templates/__init__.py similarity index 65% rename from test/app/templates/__init__.py rename to test/templates/__init__.py index 5377074..2f33d8a 100644 --- a/test/app/templates/__init__.py +++ b/test/templates/__init__.py @@ -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 diff --git a/test/app/templates/routes.py b/test/templates/routes.py similarity index 89% rename from test/app/templates/routes.py rename to test/templates/routes.py index e4ad82e..b27ece4 100644 --- a/test/app/templates/routes.py +++ b/test/templates/routes.py @@ -1,6 +1,6 @@ import json +from test.templates import bp -from app.templates import bp from flask import render_template, request diff --git a/test/app/utilities/__init__.py b/test/utilities/__init__.py similarity index 65% rename from test/app/utilities/__init__.py rename to test/utilities/__init__.py index c436436..79db77b 100644 --- a/test/app/utilities/__init__.py +++ b/test/utilities/__init__.py @@ -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 diff --git a/test/app/utilities/routes.py b/test/utilities/routes.py similarity index 91% rename from test/app/utilities/routes.py rename to test/utilities/routes.py index d9f3abb..d452e2d 100644 --- a/test/app/utilities/routes.py +++ b/test/utilities/routes.py @@ -1,6 +1,6 @@ import json +from test.utilities import bp -from app.utilities import bp from flask import render_template, request diff --git a/test/app/utilities/test-templates/grid.html b/test/utilities/test-templates/grid.html similarity index 100% rename from test/app/utilities/test-templates/grid.html rename to test/utilities/test-templates/grid.html