'Regression test for duplicate username logic in manage.py'

@mock.patch('__builtin__.raw_input', return_value='N')
@mock.patch('manage.getpass', return_value='testtesttest')
@mock.patch('sys.stdout', new_callable=StringIO)
def test_exception_handling_when_duplicate_username(self, mock_raw_input, mock_getpass, mock_stdout):

    return_value = manage._add_user()
    self.assertEqual(return_value, 0)
    self.assertIn('successfully    added', sys.stdout.getvalue())
    return_value = manage._add_user()
    self.assertEqual(return_value, 1)
    self.assertIn('ERROR:    That    username    is    already    taken!', sys.stdout.getvalue())
