Skip to content

Commit

Permalink
tests: set default id to name
Browse files Browse the repository at this point in the history
  • Loading branch information
jrcastro2 committed Aug 8, 2023
1 parent 484d992 commit 87924e5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
12 changes: 11 additions & 1 deletion run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,18 @@ set -o errexit
# Quit on unbound symbols
set -o nounset

# Check for arguments
pytest_args=()
for arg in $@; do
case ${arg} in
*)
pytest_args+=( ${arg} )
;;
esac
done

python -m check_manifest --ignore ".*-requirements.txt"
python -m sphinx.cmd.build -qnN docs docs/_build/html
python -m pytest
python -m pytest ${pytest_args[@]+"${pytest_args[@]}"}
tests_exit_code=$?
exit "$tests_exit_code"
6 changes: 6 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ class Role(db.Model, RoleMixin):
name = db.Column(db.String(80), unique=True)
description = db.Column(db.String(255))

def __init__(self, **kwargs):
if kwargs.get("name"):
kwargs.setdefault("id", kwargs.get("name"))
super().__init__(**kwargs)


class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(255), unique=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def logout(client, endpoint=None, **kwargs):

def create_roles(ds):
for role in ('admin', 'editor', 'author'):
ds.create_role(id=role, name=role)
ds.create_role(name=role)
ds.commit()


Expand Down

0 comments on commit 87924e5

Please sign in to comment.