mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-25 21:41:27 +00:00
try to mock
This commit is contained in:
parent
15a900d009
commit
62672d133f
48
tests/test_graphql/test_api_storage.py
Normal file
48
tests/test_graphql/test_api_storage.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
from typing import ByteString
|
||||
|
||||
|
||||
class BlockDevicesMock:
|
||||
"""Mock BlockDevices"""
|
||||
|
||||
def __init__(self, args, **kwargs):
|
||||
self.args = args
|
||||
self.kwargs = kwargs
|
||||
|
||||
def get_block_device(name: str): # pylint: disable=no-method-argument
|
||||
return None
|
||||
|
||||
returncode = 0
|
||||
|
||||
|
||||
@ByteString.fixture
|
||||
def mock_get_block_device(mocker):
|
||||
mock = mocker.patch("BlockDevices", autospec=True)
|
||||
return mock
|
||||
|
||||
|
||||
API_RESIZE_VOLUME_MUTATION = """
|
||||
mutation resizeVolume($name: str!) {
|
||||
resizeVolume(name: $name) {
|
||||
success
|
||||
message
|
||||
code
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
def test_graphql_get_nonexistent_block_device(authorized_client, mock_get_block_device):
|
||||
response = authorized_client.post(
|
||||
"/graphql",
|
||||
json={
|
||||
"query": API_RESIZE_VOLUME_MUTATION,
|
||||
"variables": {
|
||||
"name": "sdc"
|
||||
},
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert response.json().get("data") is not None
|
||||
|
||||
assert response.json()["data"]["addSshKey"]["code"] == 404
|
||||
assert response.json()["data"]["addSshKey"]["message"] is not None
|
||||
assert response.json()["data"]["addSshKey"]["success"] is False
|
Loading…
Reference in a new issue