Skip to content

Commit

Permalink
Renamed management commands
Browse files Browse the repository at this point in the history
Django doesn't namespace the commands, which make them
look ambiguous when used. Including `two_factor_` in the name
makes them unambiguous.

See also #77.
  • Loading branch information
Bouke committed Dec 11, 2014
1 parent 13d1dc6 commit 76866dd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions docs/management-commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Management Commands

Status
------
.. autoclass:: two_factor.management.commands.status.Command
.. autoclass:: two_factor.management.commands.two_factor_status.Command

Disable
-------
.. autoclass:: two_factor.management.commands.disable.Command
.. autoclass:: two_factor.management.commands.two_factor_disable.Command
18 changes: 9 additions & 9 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -981,22 +981,22 @@ def _assert_raises(self, err_type, err_message):

def test_raises(self):
with self._assert_raises(CommandError, 'User "some_username" does not exist'):
call_command('disable', 'some_username')
call_command('two_factor_disable', 'some_username')

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

def test_disable_single(self):
user = self.create_user()
self.enable_otp(user)
call_command('disable', '[email protected]')
call_command('two_factor_disable', '[email protected]')
self.assertEqual(list(devices_for_user(user)), [])

def test_happy_flow_multiple(self):
usernames = ['user%[email protected]' % i for i in range(0, 3)]
users = [self.create_user(username) for username in usernames]
[self.enable_otp(user) for user in users]
call_command('disable', *usernames[:2])
call_command('two_factor_disable', *usernames[:2])
self.assertEqual(list(devices_for_user(users[0])), [])
self.assertEqual(list(devices_for_user(users[1])), [])
self.assertNotEqual(list(devices_for_user(users[2])), [])
Expand All @@ -1015,27 +1015,27 @@ def setUp(self):

def test_raises(self):
with self._assert_raises(CommandError, 'User "some_username" does not exist'):
call_command('status', 'some_username')
call_command('two_factor_status', 'some_username')

with self._assert_raises(CommandError, 'User "other_username" does not exist'):
call_command('status', 'other_username', 'some_username')
call_command('two_factor_status', 'other_username', 'some_username')

def test_status_single(self):
user = self.create_user()
stdout = StringIO()
call_command('status', '[email protected]', stdout=stdout)
call_command('two_factor_status', '[email protected]', stdout=stdout)
self.assertEqual(stdout.getvalue(), '[email protected]: disabled\n')

stdout = StringIO()
self.enable_otp(user)
call_command('status', '[email protected]', stdout=stdout)
call_command('two_factor_status', '[email protected]', stdout=stdout)
self.assertEqual(stdout.getvalue(), '[email protected]: enabled\n')

def test_status_mutiple(self):
users = [self.create_user(n) for n in ['[email protected]', '[email protected]']]
self.enable_otp(users[0])
stdout = StringIO()
call_command('status', '[email protected]', '[email protected]', stdout=stdout)
call_command('two_factor_status', '[email protected]', '[email protected]', stdout=stdout)
self.assertEqual(stdout.getvalue(), '[email protected]: enabled\n'
'[email protected]: disabled\n')

Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 76866dd

Please sign in to comment.