Skip to content

Commit

Permalink
✅ Add test for kf_id fields
Browse files Browse the repository at this point in the history
  • Loading branch information
dankolbman committed Aug 6, 2020
1 parent fcba276 commit 4caa484
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/test_fields.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from django.db import models
from django.contrib.auth import get_user_model
from creator.fields import KFIDField
from creator.fields import KFIDField, kf_id_generator
from creator.studies.models import Study
from creator.files.models import File

Expand All @@ -22,6 +22,14 @@ def test_kf_id_prefix_value(db):
assert File.objects.get(kf_id=kf_id) == f


def test_wrong_len():
""" Test that kf_ids must use a two character prefix """
with pytest.raises(ValueError) as err:
kf_id = kf_id_generator("ABC")

assert "of length 2" in err


def test_user_display_name(db):
user = User(username="user", first_name="Test", last_name=None)
assert user.display_name == "Test"
Expand Down

0 comments on commit 4caa484

Please sign in to comment.