Skip to content
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

WIP Fix #1336 tests #1337

Open
wants to merge 17 commits into
base: master
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
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ draft.toml
charts/
NOTICE
LICENSE
README.md
data.db*
venv
.venv
__pycache__
dist
.git
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ tests/browser-automated-tests-playwright/e2e/*-snapshots
subscribie/static/*
subscribie/custom_pages/*
playwright-report
tests/browser-automated-tests-playwright
.terraform
*.pkl
emails
Expand Down
12 changes: 4 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
# syntax = docker/dockerfile:experimental
FROM python:3.9-slim-bullseye
FROM python:3.12-slim-bullseye
WORKDIR /usr/src/app
RUN pip install --upgrade pip
RUN apt-get update && apt-get install -y \
libffi-dev libcurl4-openssl-dev bash git gcc sqlite3 \
libffi-dev libcurl4-openssl-dev bash gcc sqlite3 \
build-essential curl

# Rust is required for Building cryptography (TODO turn this into multistage build)
RUN curl --proto '=https' --tlsv1.2 https://sh.rustup.rs > rustup.sh && sh rustup.sh -y
COPY . /usr/src/app/subscribie/
WORKDIR /usr/src/app/subscribie/
RUN --mount=type=cache,target=/root/.cache/pip . $HOME/.cargo/env && pip install -r requirements.txt
RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.lock
RUN --mount=type=cache,target=/root/.cache/pip pip install uwsgi
RUN export FLASK_APP=subscribie;
EXPOSE 80
EXPOSE 5000
ENTRYPOINT [ "./entrypoint.sh" ]
1 change: 1 addition & 0 deletions docs/content/en/docs/Architecture/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ locally.
```
export PLAYWRIGHT_HEADLESS=false
export PLAYWRIGHT_HOST=http://127.0.0.1:5000/
export [email protected]
```

#### Run playwright tests:
Expand Down
36 changes: 17 additions & 19 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,30 @@ set -euxo pipefail
export FLASK_APP=subscribie
export FLASK_DEBUG=1

if [ -a .env ]
if [ -a settings.yaml ]
then
echo ".env exists already so not copying from .env.example"
echo "settings.yaml.example exists already so not copying from settings.yaml.example"
else
echo ".env not found, so copying from .env.example"
cp .env.example .env
echo "settings.yaml not found, so copying from settings.yaml.example"
cp settings.yaml.example settings.yaml
if [ ! -d "modules" ]; then
echo creating modules directory because it didn\'t exit
mkdir modules
fi

# Set DB URI & PATH
sed -i 's#SQLALCHEMY_DATABASE_URI.*#SQLALCHEMY_DATABASE_URI: "sqlite:////usr/src/app/data.db"#g' settings.yaml
sed -i 's#DB_FULL_PATH.*#DB_FULL_PATH: "/usr/src/app/data.db"#g' settings.yaml

# Set static dir
sed -i 's#TEMPLATE_BASE_DIR.*#TEMPLATE_BASE_DIR: "/usr/src/app/subscribie/subscribie/themes/"#g' settings.yaml
sed -i 's#UPLOADED_IMAGES_DEST.*#UPLOADED_IMAGES_DEST: "/usr/src/app/subscribie/subscribie/static/"#g' settings.yaml
fi

# Set DB URI & PATH
sed -i 's#SQLALCHEMY_DATABASE_URI.*#SQLALCHEMY_DATABASE_URI="sqlite:////usr/src/app/data.db"#g' .env
sed -i 's#DB_FULL_PATH.*#DB_FULL_PATH=/usr/src/app/data.db#g' .env

# Set cookie secure flag to false in development
sed -i 's#SESSION_COOKIE_SECURE.*##g' .env
sed -i 's#SESSION_COOKIE_SAMESITE.*#Lax#g' .env

# Remove SERVER_NAME app config in docker environment
sed -i 's#SERVER_NAME.*##g' .env

# Set static dir
sed -i 's#TEMPLATE_BASE_DIR.*#TEMPLATE_BASE_DIR=/usr/src/app/subscribie/subscribie/themes/#g' .env
sed -i 's#UPLOADED_IMAGES_DEST.*#UPLOADED_IMAGES_DEST=/usr/src/app/subscribie/subscribie/static/#g' .env

flask db upgrade

flask initdb

exec uwsgi --http :80 --workers 1 --threads 2 --wsgi-file subscribie.wsgi --touch-chain-reload subscribie.wsgi --chdir /usr/src/app/subscribie/
exec uwsgi --http :5000 --workers 1 --threads 2 --wsgi-file subscribie.wsgi --touch-chain-reload subscribie.wsgi --chdir /usr/src/app/subscribie/

2 changes: 1 addition & 1 deletion migrations/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def process_revision_directives(context, revision, directives):
connection=connection,
target_metadata=target_metadata,
process_revision_directives=process_revision_directives,
**current_app.extensions["migrate"].configure_args
**current_app.extensions["migrate"].configure_args,
)

with context.begin_transaction():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2022-04-07 17:49:50.146114

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2022-04-07 17:33:30.075127

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""association_table_plan_question

Revision ID: 063ddc60bef1
Revises: c5bec71f1499
Create Date: 2024-05-09 22:00:42.022150

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "063ddc60bef1"
down_revision = "c5bec71f1499"
branch_labels = None
depends_on = None


def upgrade():
op.create_table(
"plan_question_associations",
sa.Column("question_id", sa.Integer(), nullable=True),
sa.Column("plan_id", sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(
["plan_id"],
["plan.id"],
),
sa.ForeignKeyConstraint(
["question_id"],
["question.id"],
),
)


def downgrade():
pass
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2020-12-04 14:59:11.346386

"""

from alembic import op


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2021-05-04 22:55:42.753614

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2020-11-11 12:08:45.878277

"""

from alembic import op
import sqlalchemy as sa

Expand Down
22 changes: 22 additions & 0 deletions migrations/versions/1d4b6d333c16_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""empty message

Revision ID: 1d4b6d333c16
Revises: c7a493cd99d4
Create Date: 2024-05-18 20:05:40.299194

"""


# revision identifiers, used by Alembic.
revision = "1d4b6d333c16"
down_revision = "c7a493cd99d4"
branch_labels = None
depends_on = None


def upgrade():
pass


def downgrade():
pass
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-09-01 19:35:12.241628

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2021-03-24 22:54:05.568960

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2021-05-09 21:28:01.250318

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2022-12-23 14:50:18.143177

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2020-11-02 11:21:21.027943

"""

from alembic import op


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2021-02-28 23:13:51.486171

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""add order to association_table_plan_question

Revision ID: 3a54f4b1187d
Revises: 1d4b6d333c16
Create Date: 2024-05-19 18:13:11.397272

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "3a54f4b1187d"
down_revision = "1d4b6d333c16"
branch_labels = None
depends_on = None


def upgrade():
with op.batch_alter_table("plan_question_associations", schema=None) as batch_op:
batch_op.add_column(sa.Column("order", sa.Integer(), nullable=True))


def downgrade():
pass
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2021-05-31 21:24:34.681376

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2020-09-23 17:17:30.127947

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2022-11-17 01:07:18.115335

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2024-02-11 17:21:19.287478

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2022-06-07 22:47:55.495926

"""

from alembic import op
import sqlalchemy as sa

Expand Down
1 change: 1 addition & 0 deletions migrations/versions/500f2d55c5d3_add_logintoken_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2021-02-13 00:04:37.827539

"""

from alembic import op
import sqlalchemy as sa

Expand Down
1 change: 1 addition & 0 deletions migrations/versions/53840eddbb0f_add_taxrate_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2021-03-06 17:26:15.092902

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2022-05-30 01:22:09.158426

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2020-11-02 11:54:29.263880

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""add primary plan_question_associations

Revision ID: 57b068821280
Revises: 3a54f4b1187d
Create Date: 2024-05-19 19:58:41.527688

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "57b068821280"
down_revision = "3a54f4b1187d"
branch_labels = None
depends_on = None


def upgrade():
with op.batch_alter_table("plan_question_associations", schema=None) as batch_op:
batch_op.alter_column("question_id", existing_type=sa.INTEGER(), nullable=False)
batch_op.alter_column("plan_id", existing_type=sa.INTEGER(), nullable=False)


def downgrade():
pass
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2022-07-25 22:27:45.930134

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2022-01-09 23:51:16.207317

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Loading
Loading