forked from HHS/TANF-app
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
74730d0
commit 3e2c6e2
Showing
5 changed files
with
51 additions
and
9 deletions.
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
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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"""Test signals.""" | ||
import pytest | ||
from unittest.mock import patch | ||
from tdpservice.users.models import User | ||
from tdpservice.users.test.factories import AdminUserFactory | ||
from django.contrib.auth.models import Group | ||
import logging | ||
import django | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_my_signal_receiver(mocker): | ||
"""Test my_signal_receiver.""" | ||
with patch("django.db.models.signals.m2m_changed.send") as mock_receiver: | ||
instance = AdminUserFactory.create() | ||
instance.groups.add(Group.objects.get(name="OFA System Admin")) | ||
|
||
mock_receiver.assert_called_with( | ||
sender=User.groups.through, | ||
instance=instance, | ||
action="post_add", | ||
pk_set={Group.objects.get(name="OFA System Admin").pk}, | ||
reverse=False, | ||
using="default", | ||
model=django.contrib.auth.models.Group, | ||
) | ||
mock_receiver.call_count = 2 # pre_save and post_save | ||
|
||
with patch( | ||
"tdpservice.users.signals.email_system_owner_system_admin_role_change" | ||
) as mock_email_system_owner_system_admin_role_change: | ||
instance = AdminUserFactory.create() | ||
instance.groups.add(Group.objects.get(name="OFA System Admin")) | ||
mock_email_system_owner_system_admin_role_change.assert_called_once() |