Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Konecny <[email protected]>
  • Loading branch information
Zlopez committed Dec 5, 2024
1 parent e53492e commit 575883d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@

from alembic import op


# revision identifiers, used by Alembic.
revision = 'ebc827e80373'
down_revision = '8ba7d4c42044'
revision = "ebc827e80373"
down_revision = "8ba7d4c42044"


def upgrade():
"""Alembic migration."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint('ix_users_username', 'users', type_='unique')
op.drop_constraint("ix_users_username", "users", type_="unique")
# ### end Alembic commands ###


def downgrade():
"""Downgrade migration."""
# ### commands auto generated by Alembic - please adjust! ###
op.create_unique_constraint('ix_users_username', 'users', ['username'])
op.create_unique_constraint("ix_users_username", "users", ["username"])
# ### end Alembic commands ###
15 changes: 15 additions & 0 deletions anitya/tests/db/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,21 @@ def test_is_admin_configured(self):
self.assertTrue(user.is_admin)
self.assertTrue(user.admin)

def test_is_admin_configured_email(self):
"""Assert default value for admin flag."""
user = models.User(email="[email protected]", username="user", admin=False)
self.session.add(user)
self.session.commit()

mock_dict = mock.patch.dict(
"anitya.config.config", {"ANITYA_WEB_ADMINS": [six.text_type(user.email)]}
)

with mock_dict:
self.assertFalse(user.admin)
self.assertTrue(user.is_admin)
self.assertTrue(user.admin)

def test_to_dict(self):
"""Assert the correct dictionary is returned."""
user = models.User(email="[email protected]", username="user")
Expand Down

0 comments on commit 575883d

Please sign in to comment.