Compare commits
5 Commits
f9babd73b9
...
ea5b3e3b66
Author | SHA1 | Date |
---|---|---|
Nikolai | ea5b3e3b66 | |
Nikolai | 592becff2d | |
Nikolai | 4af22ad863 | |
Nikolai | 2f568fb385 | |
Nikolai | 1e9405bad0 |
|
@ -48,4 +48,4 @@ def create(
|
|||
)
|
||||
db.session.add(new_lexicon)
|
||||
db.session.commit()
|
||||
return new_lexicon
|
||||
return new_lexicon
|
||||
|
|
|
@ -21,7 +21,7 @@ def create(
|
|||
# Verify lexicon id
|
||||
if not isinstance(lexicon_id, int):
|
||||
raise ArgumentError('Lexicon id must be an integer.')
|
||||
|
||||
|
||||
# Verify user_id
|
||||
if not (isinstance(user_id, int) or user_id is None):
|
||||
raise ArgumentError('User id must be an integer.')
|
||||
|
@ -39,4 +39,4 @@ def create(
|
|||
)
|
||||
db.session.add(new_post)
|
||||
db.session.commit()
|
||||
return new_post
|
||||
return new_post
|
|
@ -12,7 +12,7 @@ from .test_db import db
|
|||
|
||||
def test_create_post(db):
|
||||
"""Test new post creation"""
|
||||
|
||||
|
||||
# Make user and lexicon
|
||||
new_user = userq.create(db, 'username', 'password', 'user', 'a@b.c', False)
|
||||
assert new_user.id, 'Failed to create user'
|
||||
|
@ -22,7 +22,7 @@ def test_create_post(db):
|
|||
# Add the user to the lexicon as an editor
|
||||
mem = memq.create(db, new_user.id, new_lexicon.id, True)
|
||||
assert mem, 'Failed to create membership'
|
||||
|
||||
|
||||
# argument dictionary for post object
|
||||
kwargs = {
|
||||
'lexicon_id': new_lexicon.id,
|
||||
|
@ -43,7 +43,7 @@ def test_create_post(db):
|
|||
postq.create(db, **{**kwargs, 'user_id': ''})
|
||||
with pytest.raises(ArgumentError):
|
||||
postq.create(db, **{**kwargs, 'body': ''})
|
||||
|
||||
|
||||
# post with only whitespace doesn't work
|
||||
with pytest.raises(ArgumentError):
|
||||
postq.create(db, **{**kwargs, 'body': ' '})
|
||||
|
@ -58,4 +58,4 @@ def test_create_post(db):
|
|||
# post creation works when user is None
|
||||
new_post = postq.create(db, **{**kwargs, 'user_id': None})
|
||||
assert new_post
|
||||
assert new_post.user_id is None
|
||||
assert new_post.user_id is None
|
Loading…
Reference in New Issue