mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 09:26:08 -05:00
Added versions file for initial db and fixed tests.
This commit is contained in:
52
migrations/versions/0001_initialise_data.py
Normal file
52
migrations/versions/0001_initialise_data.py
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 0001_initialise_data
|
||||||
|
Revises: None
|
||||||
|
Create Date: 2016-01-12 09:33:29.249042
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '0001_initialise_data'
|
||||||
|
down_revision = None
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.create_table('services',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('name', sa.String(length=255), nullable=False),
|
||||||
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||||
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
|
sa.Column('active', sa.Boolean(), nullable=False),
|
||||||
|
sa.Column('limit', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('restricted', sa.Boolean(), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.create_table('users',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('email_address', sa.String(length=255), nullable=False),
|
||||||
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||||
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.create_index(op.f('ix_users_email_address'), 'users', ['email_address'], unique=True)
|
||||||
|
op.create_table('user_to_service',
|
||||||
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('service_id', sa.Integer(), nullable=True),
|
||||||
|
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||||
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], )
|
||||||
|
)
|
||||||
|
### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_table('user_to_service')
|
||||||
|
op.drop_index(op.f('ix_users_email_address'), table_name='users')
|
||||||
|
op.drop_table('users')
|
||||||
|
op.drop_table('services')
|
||||||
|
### end Alembic commands ###
|
||||||
@@ -88,6 +88,7 @@ def test_post_service_multiple_users(notify_api, notify_db, notify_db_session, s
|
|||||||
assert json_resp['data']['limit'] == service.limit
|
assert json_resp['data']['limit'] == service.limit
|
||||||
assert len(service.users) == 2
|
assert len(service.users) == 2
|
||||||
|
|
||||||
|
|
||||||
def test_post_service_without_users_attribute(notify_api, notify_db, notify_db_session):
|
def test_post_service_without_users_attribute(notify_api, notify_db, notify_db_session):
|
||||||
"""
|
"""
|
||||||
Tests POST endpoint '/' to create a service without 'users' attribute.
|
Tests POST endpoint '/' to create a service without 'users' attribute.
|
||||||
@@ -208,6 +209,3 @@ def test_put_service_remove_user(notify_api, notify_db, notify_db_session, sampl
|
|||||||
assert len(json_resp['data']['users']) == 1
|
assert len(json_resp['data']['users']) == 1
|
||||||
assert sample_user.id not in json_resp['data']['users']
|
assert sample_user.id not in json_resp['data']['users']
|
||||||
assert another_user.id in json_resp['data']['users']
|
assert another_user.id in json_resp['data']['users']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,10 +34,6 @@ def notify_db(notify_api, request):
|
|||||||
config.set_main_option("script_location", ALEMBIC_CONFIG)
|
config.set_main_option("script_location", ALEMBIC_CONFIG)
|
||||||
|
|
||||||
with notify_api.app_context():
|
with notify_api.app_context():
|
||||||
# TODO this next line shouldn't be needed,
|
|
||||||
# but cannot work out the import order to
|
|
||||||
# remove it.
|
|
||||||
db.create_all()
|
|
||||||
upgrade(config, 'head')
|
upgrade(config, 'head')
|
||||||
|
|
||||||
def teardown():
|
def teardown():
|
||||||
|
|||||||
Reference in New Issue
Block a user