-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement method to return a user's transit agency
- Loading branch information
1 parent
e00240c
commit d4f04fc
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from django.conf import settings | ||
from django.contrib.auth.models import Group, User | ||
from django.core.exceptions import ValidationError | ||
|
||
import pytest | ||
|
@@ -464,3 +465,18 @@ def test_TransitAgency_all_active(model_TransitAgency): | |
assert len(result) > 0 | ||
assert model_TransitAgency in result | ||
assert inactive_agency not in result | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_TransitAgency_for_user(model_TransitAgency): | ||
group = Group.objects.create(name="test_group") | ||
|
||
agency_for_user = TransitAgency.by_id(model_TransitAgency.id) | ||
agency_for_user.pk = None | ||
agency_for_user.group = group | ||
agency_for_user.save() | ||
|
||
user = User.objects.create_user(username="test_user", email="[email protected]", password="test", is_staff=True) | ||
user.groups.add(group) | ||
|
||
assert TransitAgency.for_user(user) == agency_for_user |