Skip to content

Commit

Permalink
Added test for disable command
Browse files Browse the repository at this point in the history
  • Loading branch information
Bouke committed May 8, 2014
1 parent 6b70a02 commit 29f865a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from binascii import unhexlify
from django.core.management import call_command, CommandError
import qrcode.image.svg

try:
Expand Down Expand Up @@ -759,3 +760,27 @@ class TestForm(forms.Form):
self.assertIn('number', form.errors)
self.assertEqual(form.errors['number'],
[six.text_type(phone_number_validator.message)])


class DisableCommandTest(UserMixin, TestCase):
def test_raises(self):
with self.assertRaisesMessage(CommandError, 'User "some_username" does not exist'):
call_command('disable', 'some_username')

with self.assertRaisesMessage(CommandError, 'User "other_username" does not exist'):
call_command('disable', 'other_username', 'some_username')

def test_disable_single(self):
user = self.create_user()
self.enable_otp(user)
call_command('disable', 'bouke@example.com')
self.assertEqual(list(devices_for_user(user)), [])

def test_happy_flow_multiple(self):
users = [self.create_user(n) for n in ['user0@example.com', 'user1@example.com']]
for u in users:
self.enable_otp(u)
call_command('disable', 'user0@example.com', 'user1@example.com')
self.assertEqual(list(devices_for_user(users[0])), [])
self.assertEqual(list(devices_for_user(users[1])), [])

0 comments on commit 29f865a

Please sign in to comment.