Skip to content

Commit 020efcc

Browse files
authored
Merge pull request #276 from VariantEffect/release-2024.2.3
Release 2024.2.3 as part of 2024.3.0
2 parents 53a6144 + b59351d commit 020efcc

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""Make Index on Users Unique
2+
3+
Revision ID: 44a45d616036
4+
Revises: ec5d2787bec9
5+
Create Date: 2024-08-16 13:25:14.980820
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
# revision identifiers, used by Alembic.
12+
revision = "44a45d616036"
13+
down_revision = "ec5d2787bec9"
14+
branch_labels = None
15+
depends_on = None
16+
17+
18+
def upgrade():
19+
# ### commands auto generated by Alembic - please adjust! ###
20+
op.drop_index("ix_users_username", table_name="users")
21+
op.create_index(op.f("ix_users_username"), "users", ["username"], unique=True)
22+
# ### end Alembic commands ###
23+
24+
25+
def downgrade():
26+
# ### commands auto generated by Alembic - please adjust! ###
27+
op.drop_index(op.f("ix_users_username"), table_name="users")
28+
op.create_index("ix_users_username", "users", ["username"], unique=False)
29+
# ### end Alembic commands ###

src/mavedb/models/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class User(Base):
2020
__tablename__ = "users"
2121

2222
id = Column(Integer, primary_key=True)
23-
username = Column(String, index=True, nullable=False)
23+
username = Column(String, index=True, nullable=False, unique=True)
2424
first_name = Column(String, nullable=True)
2525
last_name = Column(String, nullable=True)
2626
email = Column(String, nullable=True)

tests/lib/test_authentication.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,6 @@ async def test_get_current_user_nonexistent_user(session, setup_lib_db, with_ema
112112
session.commit()
113113

114114

115-
@pytest.mark.asyncio
116-
async def test_get_current_user_user_exists_twice(session, setup_lib_db):
117-
session.add(User(**TEST_USER))
118-
session.commit()
119-
120-
with pytest.raises(MultipleResultsFound) as exc_info:
121-
await get_current_user(None, TEST_USER_DECODED_JWT, session, None)
122-
assert "Multiple rows were found when one or none was required" in str(exc_info.value)
123-
124-
# Some lingering db transaction holds this test open unless it is explicitly closed.
125-
session.commit()
126-
127-
128115
@pytest.mark.asyncio
129116
async def test_get_current_user_user_is_inactive(session, setup_lib_db):
130117
mark_user_inactive(session, TEST_USER["username"])

0 commit comments

Comments
 (0)