예제 #1
0
 def test_create_superuser_command_no_email(self, testdir_class,
                                            test_utils):
     testdir_class.activate()
     username = test_utils.random_string(5)
     password = test_utils.random_string(5)
     commands.createsuperuser_command(username,
                                      None,
                                      password,
                                      no_input=True)
     user = Users.get_user_by_username(username)
     assert user.email is None
예제 #2
0
 def test_create_superuser_command_invalid_email(self, testdir_class,
                                                 test_utils, capsys):
     testdir_class.activate()
     username = test_utils.random_string(5)
     email = 'test@'
     password = test_utils.random_string(5)
     with pytest.raises(SystemExit) as wrapped_execution:
         commands.createsuperuser_command(username,
                                          email,
                                          password,
                                          no_input=True)
     assert wrapped_execution.value.code == 1
     captured = capsys.readouterr()
     assert f'Error: {email} is not a valid email address' in captured.out
예제 #3
0
 def test_create_superuser_command(self, testdir_class, test_utils, capsys):
     testdir_class.activate()
     username = test_utils.random_string(5)
     email = test_utils.random_email()
     password = test_utils.random_string(5)
     commands.createsuperuser_command(username,
                                      email,
                                      password,
                                      no_input=True)
     out, err = capsys.readouterr()
     assert f'Superuser {username} was created successfully.' in out
     assert Users.user_exists(username)
     user = Users.get_user_by_username(username)
     assert user.email == email