-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from libris/bugfix/no-passwd
Bugfix/no passwd
- Loading branch information
Showing
7 changed files
with
59 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
migrations/versions/c9e1cd58c4a7_make_user_password_friends_non_nullable.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Make user password and friends non-nullable. | ||
Revision ID: c9e1cd58c4a7 | ||
Revises: bc2c31758e2a | ||
Create Date: 2017-10-26 16:19:22.453941 | ||
""" | ||
|
||
from __future__ import absolute_import, division, print_function, unicode_literals | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# Revision identifiers, used by Alembic. | ||
revision = 'c9e1cd58c4a7' | ||
down_revision = 'bc2c31758e2a' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
"""Make columns 'active', 'is_admin' and 'password' non-nullable.""" | ||
with op.batch_alter_table('users', schema=None) as batch_op: | ||
batch_op.alter_column('active', existing_type=sa.BOOLEAN(), nullable=False) | ||
batch_op.alter_column('is_admin', existing_type=sa.BOOLEAN(), nullable=False) | ||
batch_op.alter_column('password', existing_type=sa.BLOB(), nullable=False) | ||
|
||
|
||
def downgrade(): | ||
"""Make things nullable again.""" | ||
with op.batch_alter_table('users', schema=None) as batch_op: | ||
batch_op.alter_column('password', existing_type=sa.BLOB(), nullable=True) | ||
batch_op.alter_column('is_admin', existing_type=sa.BOOLEAN(), nullable=True) | ||
batch_op.alter_column('active', existing_type=sa.BOOLEAN(), nullable=True) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,11 +33,11 @@ def test_created_at_defaults_to_datetime(): | |
|
||
|
||
@pytest.mark.usefixtures('db') | ||
def test_password_is_nullable(): | ||
"""Test null password.""" | ||
def test_password_defaults_to_a_random_one(): | ||
"""Test empty password field is assigned some random password, instead of being set to tull.""" | ||
user = User(email='[email protected]', full_name='Mr. Foo Bar') | ||
user.save() | ||
assert user.password is None | ||
assert user.password is not None | ||
|
||
|
||
@pytest.mark.usefixtures('db') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters