aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/users
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-05-31 10:41:53 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-05-31 10:41:53 +0100
commit9917bd1793d0362b84704d0ad4409be4ec9dbdd3 (patch)
treeaa79d250353e148067eb7e4bd72ae32116c7b0d7 /ctrack/users
parent2adf4f28ec512b654a4802e274ad683d6c670fc5 (diff)
parent10579be5293908b57336ecd769b8e17a610e008a (diff)
Merge branch 'incident-report-form' of github.com:hammerheadlemon/ctrack into incident-report-form
Diffstat (limited to '')
-rw-r--r--ctrack/users/tests/test_credentials.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/ctrack/users/tests/test_credentials.py b/ctrack/users/tests/test_credentials.py
new file mode 100644
index 0000000..7538643
--- /dev/null
+++ b/ctrack/users/tests/test_credentials.py
@@ -0,0 +1,30 @@
+"""
+THIS TEST IS FROM REALPYTHON ARTICLE
+https://realpython.com/django-pytest-fixtures/
+
+The permissions here are not optimal for this project yet.
+TODO - make them so!
+"""
+import pytest
+from django.contrib.auth import get_user_model
+from django.contrib.auth.models import Group, Permission
+
+
+@pytest.fixture
+def user_A(db) -> Group:
+ group = Group.objects.create(name="cct_user")
+ change_user_permissions = Permission.objects.filter(
+ codename__in=["change_user", "view_user"],
+ )
+ group.permissions.add(*change_user_permissions)
+ user = get_user_model().objects.create_user("A")
+ user.groups.add(group)
+ return user
+
+
+def test_should_create_user(user_A: get_user_model()) -> None:
+ assert user_A.username == "A"
+
+
+def test_user_is_in_app_user_group(user_A: get_user_model()) -> None:
+ assert user_A.groups.filter(name="cct_user").exists()