|
3 | 3 |
|
4 | 4 | from compiler_admin.commands import RESULT_FAILURE, RESULT_SUCCESS
|
5 | 5 | from compiler_admin.commands.create import create, __name__ as MODULE
|
| 6 | +from compiler_admin.services.google import USER_HELLO |
6 | 7 |
|
7 | 8 |
|
8 | 9 | @pytest.fixture
|
@@ -50,3 +51,37 @@ def test_create_user_does_not_exists(mock_google_user_exists, mock_google_CallGA
|
50 | 51 | assert "password random changepassword" in call_args
|
51 | 52 |
|
52 | 53 | mock_google_add_user_to_group.assert_called_once()
|
| 54 | + |
| 55 | + |
| 56 | +def test_create_user_notify(mock_google_user_exists, mock_google_CallGAMCommand, mock_google_add_user_to_group): |
| 57 | + mock_google_user_exists.return_value = False |
| 58 | + |
| 59 | + args = Namespace( username="username", notify="[email protected]") |
| 60 | + res = create(args) |
| 61 | + |
| 62 | + assert res == RESULT_SUCCESS |
| 63 | + |
| 64 | + mock_google_CallGAMCommand.assert_called_once() |
| 65 | + call_args = " ".join(mock_google_CallGAMCommand.call_args[0][0]) |
| 66 | + assert "create user" in call_args |
| 67 | + assert "password random changepassword" in call_args |
| 68 | + assert f"notify [email protected] from {USER_HELLO}" in call_args |
| 69 | + |
| 70 | + mock_google_add_user_to_group.assert_called_once() |
| 71 | + |
| 72 | + |
| 73 | +def test_create_user_extras(mock_google_user_exists, mock_google_CallGAMCommand, mock_google_add_user_to_group): |
| 74 | + mock_google_user_exists.return_value = False |
| 75 | + |
| 76 | + args = Namespace(username="username") |
| 77 | + res = create(args, "extra1", "extra2") |
| 78 | + |
| 79 | + assert res == RESULT_SUCCESS |
| 80 | + |
| 81 | + mock_google_CallGAMCommand.assert_called_once() |
| 82 | + call_args = " ".join(mock_google_CallGAMCommand.call_args[0][0]) |
| 83 | + assert "create user" in call_args |
| 84 | + assert "password random changepassword" in call_args |
| 85 | + assert "extra1 extra2" in call_args |
| 86 | + |
| 87 | + mock_google_add_user_to_group.assert_called_once() |
0 commit comments