Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam-W1 committed Oct 4, 2024
1 parent 48b986a commit 39c2fc4
Show file tree
Hide file tree
Showing 10 changed files with 1,232 additions and 11 deletions.
3 changes: 0 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@
"strings": false
},
"editor.quickSuggestionsDelay": 10,
"black-formatter.interpreter": [
"/usr/local/bin/python",
],
}
6 changes: 0 additions & 6 deletions app/db/migrations/versions/~2024_10_03_1454-c3dab74013f1_.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ def upgrade():
sa.Column("schema", postgresql.JSON(none_as_null=True, astext_type=sa.Text()), nullable=True)
)

with op.batch_alter_table("page", schema=None) as batch_op:
batch_op.add_column(sa.Column("section", sa.String(), nullable=True))

with op.batch_alter_table("round", schema=None) as batch_op:
batch_op.alter_column(
"application_reminder_sent", existing_type=sa.BOOLEAN(), server_default=None, existing_nullable=False
Expand Down Expand Up @@ -143,9 +140,6 @@ def downgrade():
existing_nullable=False,
)

with op.batch_alter_table("page", schema=None) as batch_op:
batch_op.drop_column("section")

with op.batch_alter_table("component", schema=None) as batch_op:
batch_op.drop_column("schema")

Expand Down
35 changes: 35 additions & 0 deletions app/db/migrations/versions/~2024_10_04_1727-7c9fef251eca_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""empty message
Revision ID: 7c9fef251eca
Revises: c3dab74013f1
Create Date: 2024-10-04 17:27:35.183466
"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "7c9fef251eca"
down_revision = "c3dab74013f1"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("page", schema=None) as batch_op:
batch_op.add_column(
sa.Column("section", postgresql.JSON(none_as_null=True, astext_type=sa.Text()), nullable=True)
)

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("page", schema=None) as batch_op:
batch_op.drop_column("section")

# ### end Alembic commands ###
2 changes: 1 addition & 1 deletion app/db/models/application_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class Page(BaseModel):
)
source_template_id = Column(UUID(as_uuid=True), nullable=True)
controller = Column(String(), nullable=True)
section = Column(String(), nullable=True)
section = Column(JSON(none_as_null=True))

def __repr__(self):
return f"Page(/{self.display_path} - {self.name_in_apply_json['en']}, Components: {self.components})"
Expand Down
11 changes: 11 additions & 0 deletions app/shared/data_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Condition:
name: str
display_name: str
value: ConditionValue
source_page_path: str
destination_page_path: str


Expand Down Expand Up @@ -155,3 +156,13 @@ class RoundExport:

def as_dict(self):
return asdict(self)


@dataclass
class FormSection:
name: str
title: str
hideTitle: Optional[bool] = None

def as_dict(self):
return asdict(self)
3 changes: 3 additions & 0 deletions tests/test_config_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def test_generate_form_jsons_for_round_valid_input(seed_dynamic_data):
},
],
"next": [{"path": "/summary"}],
"section": None,
},
{
"path": "/intro-about-your-organisation",
Expand All @@ -199,6 +200,7 @@ def test_generate_form_jsons_for_round_valid_input(seed_dynamic_data):
],
"next": [{"path": "/organisation-name"}],
"controller": "./pages/start.js",
"section": None,
},
{
"path": "/summary",
Expand All @@ -207,6 +209,7 @@ def test_generate_form_jsons_for_round_valid_input(seed_dynamic_data):
"next": [],
"section": "uLwBuz",
"controller": "./pages/summary.js",
"section": "uLwBuz",
},
],
"lists": [
Expand Down
182 changes: 181 additions & 1 deletion tests/test_data/Contact details template.json
Original file line number Diff line number Diff line change
@@ -1 +1,181 @@
{"metadata":{},"startPage":"/lead-contact-details","pages":[{"title":"Lead contact details","path":"/lead-contact-details","components":[{"name":"rILgUu","options":{},"type":"Html","content":"<p class=\"govuk-body\">They will receive all the information about this application.</p>","schema":{}},{"name":"CgCZmL","options":{},"type":"TextField","title":"Lead contact full name","schema":{}},{"name":"XHFsXs","options":{},"type":"TextField","title":"Lead contact job title","schema":{}},{"name":"qSOFAl","options":{},"type":"EmailAddressField","title":"Lead contact email address","schema":{}},{"name":"RyHYTL","options":{},"type":"NumberField","title":"Lead contact telephone number","schema":{}}],"next":[{"path":"/is-the-lead-contact-the-same-person-as-the-authorised-signatory"}],"section":"roYQzW"},{"path":"/is-the-lead-contact-the-same-person-as-the-authorised-signatory","title":"Is the lead contact the same person as the authorised signatory?","components":[{"name":"SDJIoS","options":{"exposeToContext":true},"type":"YesNoField","title":"Is the lead contact the same person as the authorised signatory?","hint":"<p class=\"govuk-body\">An authorised signatory:</p>\n<ul class=\"govuk-list govuk-list--bullet\">\n <li>is allowed to act on behalf of the organisation</li>\n <li>will sign the grant funding agreement if your application is successful</li>\n</ul>","values":{"type":"listRef"},"schema":{}}],"next":[{"path":"/summary"},{"path":"/authorised-signatory-details","condition":"gbOJSj"}],"section":"roYQzW"},{"title":"Summary","path":"/summary","controller":"./pages/summary.js","components":[],"next":[],"section":"roYQzW"},{"path":"/authorised-signatory-details","title":"Authorised signatory details","components":[{"name":"JTDVSR","options":{},"type":"TextField","title":"Authorised signatory full name","schema":{}},{"name":"yafapW","options":{},"type":"TextField","title":"Authorised signatory job title","schema":{}},{"type":"EmailAddressField","title":"Authorised signatory email address","name":"authorised-signatory-email","nameHasError":false,"options":{"exposeToContext":false},"schema":{}},{"name":"CXrlUt","options":{},"type":"TelephoneNumberField","title":"Authorised signatory telephone number","schema":{}}],"next":[{"path":"/summary"}],"section":"roYQzW"}],"lists":[],"sections":[{"name":"roYQzW","title":"Contact details","hideTitle":false}],"conditions":[{"displayName":"Authorised signatory different from lead contact","name":"gbOJSj","value":{"name":"Authorised signatory different from lead contact","conditions":[{"field":{"name":"SDJIoS","type":"YesNoField","display":"Is the lead contact the same person as the authorised signatory?"},"operator":"is","value":{"type":"Value","value":"false","display":"false"}}]}}],"fees":[],"outputs":[],"version":2,"skipSummary":false,"feeOptions":{"allowSubmissionWithoutPayment":true,"maxAttempts":3,"showPaymentSkippedWarningPage":false},"markAsComplete":false,"name":"Contact details template (September 2024)","feedback":{"feedbackForm":false,"url":""},"phaseBanner":{}}
{
"metadata": {},
"startPage": "/lead-contact-details",
"pages": [
{
"title": "Lead contact details",
"path": "/lead-contact-details",
"components": [
{
"name": "rILgUu",
"options": {},
"type": "Html",
"content": "<p class=\"govuk-body\">They will receive all the information about this application.</p>",
"schema": {}
},
{
"name": "CgCZmL",
"options": {},
"type": "TextField",
"title": "Lead contact full name",
"schema": {}
},
{
"name": "XHFsXs",
"options": {},
"type": "TextField",
"title": "Lead contact job title",
"schema": {}
},
{
"name": "qSOFAl",
"options": {},
"type": "EmailAddressField",
"title": "Lead contact email address",
"schema": {}
},
{
"name": "RyHYTL",
"options": {},
"type": "NumberField",
"title": "Lead contact telephone number",
"schema": {}
}
],
"next": [
{
"path": "/is-the-lead-contact-the-same-person-as-the-authorised-signatory"
}
],
"section": "roYQzW"
},
{
"path": "/is-the-lead-contact-the-same-person-as-the-authorised-signatory",
"title": "Is the lead contact the same person as the authorised signatory?",
"components": [
{
"name": "SDJIoS",
"options": {
"exposeToContext": true
},
"type": "YesNoField",
"title": "Is the lead contact the same person as the authorised signatory?",
"hint": "<p class=\"govuk-body\">An authorised signatory:</p>\n<ul class=\"govuk-list govuk-list--bullet\">\n <li>is allowed to act on behalf of the organisation</li>\n <li>will sign the grant funding agreement if your application is successful</li>\n</ul>",
"values": {
"type": "listRef"
},
"schema": {}
}
],
"next": [
{
"path": "/summary"
},
{
"path": "/authorised-signatory-details",
"condition": "gbOJSj"
}
],
"section": "roYQzW"
},
{
"title": "Summary",
"path": "/summary",
"controller": "./pages/summary.js",
"components": [],
"next": [],
"section": "roYQzW"
},
{
"path": "/authorised-signatory-details",
"title": "Authorised signatory details",
"components": [
{
"name": "JTDVSR",
"options": {},
"type": "TextField",
"title": "Authorised signatory full name",
"schema": {}
},
{
"name": "yafapW",
"options": {},
"type": "TextField",
"title": "Authorised signatory job title",
"schema": {}
},
{
"type": "EmailAddressField",
"title": "Authorised signatory email address",
"name": "authorised-signatory-email",
"nameHasError": false,
"options": {
"exposeToContext": false
},
"schema": {}
},
{
"name": "CXrlUt",
"options": {},
"type": "TelephoneNumberField",
"title": "Authorised signatory telephone number",
"schema": {}
}
],
"next": [
{
"path": "/summary"
}
],
"section": "roYQzW"
}
],
"lists": [],
"sections": [
{
"name": "roYQzW",
"title": "Contact details",
"hideTitle": false
}
],
"conditions": [
{
"displayName": "Authorised signatory different from lead contact",
"name": "gbOJSj",
"value": {
"name": "Authorised signatory different from lead contact",
"conditions": [
{
"field": {
"name": "SDJIoS",
"type": "YesNoField",
"display": "Is the lead contact the same person as the authorised signatory?"
},
"operator": "is",
"value": {
"type": "Value",
"value": "false",
"display": "false"
}
}
]
}
}
],
"fees": [],
"outputs": [],
"version": 2,
"skipSummary": false,
"feeOptions": {
"allowSubmissionWithoutPayment": true,
"maxAttempts": 3,
"showPaymentSkippedWarningPage": false
},
"markAsComplete": false,
"name": "Contact details template (September 2024)",
"feedback": {
"feedbackForm": false,
"url": ""
},
"phaseBanner": {}
}
Loading

0 comments on commit 39c2fc4

Please sign in to comment.