-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from Onemind-Services-LLC/management.Account
added management.Account
- Loading branch information
Showing
4 changed files
with
246 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import datetime | ||
from unittest.mock import patch, Mock | ||
|
||
import pytest | ||
|
||
from jelastic.api import Management | ||
|
||
CURRENT_DATETIME = datetime.datetime.now() | ||
success_response = {"error": "", "reason": 0, "result": 0, "source": "billing"} | ||
|
||
__all__ = ("client", "success_response", "CURRENT_DATETIME") | ||
|
||
|
||
@pytest.fixture | ||
def client(): | ||
with patch("jelastic.api.abstract.ClientAbstract._get") as mock_get: | ||
jc = Management(session=Mock(), token="token") | ||
jc._get = mock_get | ||
yield jc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
from . import * | ||
|
||
|
||
def test_add_private_ssh_key(client): | ||
client._get.return_value = success_response | ||
response = client.Account.AddPrivateSSHKey("title", "ssh_key") | ||
client._get.assert_called_with( | ||
"AddPrivateSSHKey", | ||
params={"title": "title", "sshKey": "ssh_key"}, | ||
) | ||
assert response == success_response | ||
|
||
|
||
def test_add_public_ssh_key(client): | ||
client._get.return_value = success_response | ||
response = client.Account.AddPublicSSHKey("title", "ssh_key") | ||
client._get.assert_called_with( | ||
"AddPublicSSHKey", | ||
params={"title": "title", "sshKey": "ssh_key"}, | ||
) | ||
assert response == success_response | ||
|
||
|
||
def test_add_ssh_key(client): | ||
client._get.return_value = success_response | ||
response = client.Account.AddSSHKey("title", "ssh_key", False) | ||
client._get.assert_called_with( | ||
"AddSSHKey", | ||
params={"title": "title", "sshKey": "ssh_key", "isPrivate": False}, | ||
) | ||
assert response == success_response | ||
|
||
|
||
def test_adjust_containers_limits_or_all_users(client): | ||
client._get.return_value = success_response | ||
response = client.Account.AdjustContainersLimitsForAllUsers() | ||
client._get.AdjustContainersLimitsForAllUsers( | ||
"AddSSHKey", | ||
params={}, | ||
) | ||
assert response == success_response | ||
|
||
|
||
def test_clean_quotas_cache(client): | ||
client._get.return_value = success_response | ||
response = client.Account.CleanQuotasCache(1) | ||
client._get.assert_called_with( | ||
"CleanQuotasCache", | ||
params={ | ||
"uid": 1, | ||
}, | ||
) | ||
assert response == success_response | ||
|
||
|
||
def test_delete_ssh_key(client): | ||
client._get.return_value = success_response | ||
response = client.Account.DeleteSSHKey(1) | ||
client._get.assert_called_with( | ||
"DeleteSSHKey", | ||
params={ | ||
"id": 1, | ||
}, | ||
) | ||
assert response == success_response | ||
|
||
|
||
def test_get_quotas_by_ip_address(client): | ||
client._get.return_value = success_response | ||
response = client.Account.GetQuotasByIpAddress( | ||
"address", | ||
"quotas_names", | ||
) | ||
client._get.assert_called_with( | ||
"GetQuotasByIpAddress", | ||
params={ | ||
"ipAddress": "address", | ||
"quotasnames": "quotas_names", | ||
}, | ||
) | ||
assert response == success_response | ||
|
||
|
||
def test_get_ssh_keys(client): | ||
client._get.return_value = success_response | ||
response = client.Account.GetSSHKeys(False) | ||
client._get.assert_called_with( | ||
"GetSSHKeys", | ||
params={"isPrivate": False}, | ||
) | ||
assert response == success_response | ||
|
||
|
||
def test_get_ssh_keys_inner(client): | ||
client._get.return_value = success_response | ||
response = client.Account.GetSSHKeysInner(1) | ||
client._get.assert_called_with( | ||
"GetSSHKeysInner", | ||
params={ | ||
"uid": 1, | ||
}, | ||
) | ||
assert response == success_response |