-
-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
get all phonedevices of the user (fixes #659)
- Loading branch information
1 parent
d6d8b63
commit 52c9815
Showing
3 changed files
with
23 additions
and
2 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
Empty file.
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,21 @@ | ||
from django.test import TestCase | ||
|
||
from tests.utils import UserMixin | ||
from two_factor.plugins.phonenumber.method import PhoneCallMethod, SMSMethod | ||
|
||
class PhoneMethodBaseTestMixin(UserMixin): | ||
def test_get_devices(self): | ||
user = self.create_user() | ||
backup_device = user.phonedevice_set.create(name='backup', number='+12024561111', method=self.method.code) | ||
default_device = user.phonedevice_set.create(name='default', number='+12024561111', method=self.method.code) | ||
|
||
method_device_pks = [device.pk for device in self.method.get_devices(user)] | ||
self.assertEqual(method_device_pks, [backup_device.pk, default_device.pk]) | ||
|
||
|
||
class PhoneCallMethodTest(PhoneMethodBaseTestMixin, TestCase): | ||
method = PhoneCallMethod() | ||
|
||
|
||
class SMSMethodTest(PhoneMethodBaseTestMixin, TestCase): | ||
method = SMSMethod() |