Skip to content

Commit

Permalink
fix test: improve get_nick_id tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Exirel committed Jan 20, 2022
1 parent 33690ac commit 39541fb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ def test_get_nick_id(db):
nick = Identifier('Exirel')
session = db.session()

# Attempt to get NickIDs: it is not created by default
# Attempt to get nick ID: it is not created by default
with pytest.raises(ValueError):
db.get_nick_id(nick)

# Create the NickIDs
# Create the nick ID
nick_id = db.get_nick_id(nick, create=True)

# Check that one and only one Nicknames exist with that ID
# Check that one and only one nickname exists with that ID
nickname = session.query(Nicknames).filter(
Nicknames.nick_id == nick_id,
).one() # will raise if not one and exactly one
Expand All @@ -80,7 +80,7 @@ def test_get_nick_id_casemapping(db, name, slug, variant):
session = db.session()
nick = Identifier(name)

# Create the NickIDs
# Create the nick ID
nick_id = db.get_nick_id(nick, create=True)

registered = session.query(Nicknames) \
Expand All @@ -96,12 +96,12 @@ def test_get_nick_id_casemapping(db, name, slug, variant):
# Even if the case is different
assert nick_id == db.get_nick_id(variant)

# And no other NickIDs was created (even with create=True)
# And no other nick IDs are created (even with create=True)
assert nick_id == db.get_nick_id(name, create=True)
assert nick_id == db.get_nick_id(variant, create=True)
assert 1 == session.query(NickIDs).count()

# But a very different name means a new NickIDs
# But a truly different name means a new nick ID
new_nick_id = db.get_nick_id(name + '_test', create=True)
assert new_nick_id != nick_id
assert 2 == session.query(NickIDs).count()
Expand Down

0 comments on commit 39541fb

Please sign in to comment.