Skip to content

Commit

Permalink
feat: seperate street and city
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes1803 committed Oct 10, 2023
1 parent 182cefd commit 61f2480
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 9 deletions.
33 changes: 33 additions & 0 deletions in_concert/app/alembic/versions/bc2604359d30_add_city_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""add city field
Revision ID: bc2604359d30
Revises: 7486fdbf7149
Create Date: 2023-10-10 09:53:36.201086
"""
from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision: str = "bc2604359d30"
down_revision: Union[str, None] = "7486fdbf7149"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("venues", sa.Column("street", sa.String(length=30), nullable=False))
op.add_column("venues", sa.Column("city", sa.String(length=30), nullable=False))
op.drop_column("venues", "address")
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("venues", sa.Column("address", sa.VARCHAR(length=30), nullable=False))
op.drop_column("venues", "city")
op.drop_column("venues", "street")
# ### end Alembic commands ###
5 changes: 3 additions & 2 deletions in_concert/app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

class VenueForm(StarletteForm):
name = StringField("name", validators=[DataRequired(), Length(min=2, max=30)])
address = StringField("address", validators=[DataRequired(), Length(max=30)])
state = StringField("state", validators=[DataRequired(), Length(max=30)])
street = StringField("street", validators=[DataRequired(), Length(max=30)])
city = StringField("city", validators=[DataRequired(), Length(max=30)])
zip_code = IntegerField("zip_code", validators=[DataRequired()])
state = StringField("state", validators=[DataRequired(), Length(max=30)])
phone = IntegerField("phone", validators=[DataRequired()])
website = StringField("website", validators=[Length(max=30)])
image_link = StringField("image_link", validators=[Length(max=30)])
Expand Down
5 changes: 3 additions & 2 deletions in_concert/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ class Venue(Base):

id: Mapped[int] = mapped_column(primary_key=True)
name: Mapped[str] = mapped_column(String(30))
address: Mapped[str] = mapped_column(String(30))
state: Mapped[str] = mapped_column(String(30))
street: Mapped[str] = mapped_column(String(30))
city: Mapped[str] = mapped_column(String(30))
zip_code: Mapped[int] = mapped_column(Integer())
state: Mapped[str] = mapped_column(String(30))
phone: Mapped[int] = mapped_column(Integer())
website: Mapped[str] = mapped_column(String(30), nullable=True)
image_link: Mapped[str] = mapped_column(String(30), nullable=True)
Expand Down
3 changes: 2 additions & 1 deletion in_concert/app/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class UserSchema(BaseModel):

class VenueSchema(BaseModel):
name: str
address: str
street: str
city: str
state: str
zip_code: int
phone: int
Expand Down
11 changes: 7 additions & 4 deletions tests/unit/app/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def test_post_venue_should_return_id_of_new_venue(self, client, response_obj: Re
"/venues",
data={
"name": "venue name",
"address": "venue address",
"street": "venue street",
"city": "venue city",
"state": "venue state",
"zip_code": 12345,
"phone": 1234567890,
Expand All @@ -69,7 +70,8 @@ def test_post_venue_should_create_venue_in_db(self, client, response_obj: Respon
# response=response_obj,
data={
"name": "venue name",
"address": "venue address",
"street": "venue street",
"city": "venue city",
"state": "venue state",
"zip_code": 12345,
"phone": 1234567890,
Expand All @@ -89,7 +91,8 @@ def test_post_venue_with_missing_data_should_resend_form(self, client, response_
"/venues",
# missing name
data={
"address": "venue address",
"street": "venue street",
"city": "venue city",
"state": "venue state",
"zip_code": 12345,
"phone": 1234567890,
Expand All @@ -101,7 +104,7 @@ def test_post_venue_with_missing_data_should_resend_form(self, client, response_

html_response = response.content.decode(response.charset_encoding)
# test previous user input is saved in form if validation fails
assert 'value="venue address"' in html_response
assert 'value="venue street"' in html_response

def test_get_venue_form_should_render_venue_form(self, client):
response = client.get("/venues")
Expand Down

0 comments on commit 61f2480

Please sign in to comment.