mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-29 15:31:28 +00:00
fix tests
This commit is contained in:
parent
8d21cdcb2b
commit
3c63ab2657
|
@ -1,13 +1,10 @@
|
||||||
import pytest
|
import pytest
|
||||||
from selfprivacy_api.graphql.mutations.mutation_interface import (
|
|
||||||
GenericMutationReturn,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class BlockDeviceMockReturnNone:
|
class BlockDeviceMockReturnNone:
|
||||||
"""Mock BlockDevices"""
|
"""Mock BlockDevices"""
|
||||||
|
|
||||||
def __init__(self, args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.args = args
|
self.args = args
|
||||||
self.kwargs = kwargs
|
self.kwargs = kwargs
|
||||||
|
|
||||||
|
@ -26,7 +23,7 @@ class BlockDeviceMockReturnNone:
|
||||||
class BlockDeviceMockReturnTrue:
|
class BlockDeviceMockReturnTrue:
|
||||||
"""Mock BlockDevices"""
|
"""Mock BlockDevices"""
|
||||||
|
|
||||||
def __init__(self, args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.args = args
|
self.args = args
|
||||||
self.kwargs = kwargs
|
self.kwargs = kwargs
|
||||||
|
|
||||||
|
@ -45,7 +42,7 @@ class BlockDeviceMockReturnTrue:
|
||||||
class BlockDeviceMockReturnFalse:
|
class BlockDeviceMockReturnFalse:
|
||||||
"""Mock BlockDevices"""
|
"""Mock BlockDevices"""
|
||||||
|
|
||||||
def __init__(self, args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.args = args
|
self.args = args
|
||||||
self.kwargs = kwargs
|
self.kwargs = kwargs
|
||||||
|
|
||||||
|
@ -62,8 +59,8 @@ class BlockDeviceMockReturnFalse:
|
||||||
|
|
||||||
|
|
||||||
class BlockDevicesMockReturnTrue:
|
class BlockDevicesMockReturnTrue:
|
||||||
def get_block_device(self, name: str):
|
def get_block_device(name: str): # type: ignore
|
||||||
return True
|
return BlockDeviceMockReturnTrue()
|
||||||
|
|
||||||
def __new__(cls, *args, **kwargs):
|
def __new__(cls, *args, **kwargs):
|
||||||
pass
|
pass
|
||||||
|
@ -73,7 +70,7 @@ class BlockDevicesMockReturnTrue:
|
||||||
|
|
||||||
|
|
||||||
class BlockDevicesMockReturnNone:
|
class BlockDevicesMockReturnNone:
|
||||||
def get_block_device(self, name: str):
|
def get_block_device(name: str): # type: ignore
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def __new__(cls, *args, **kwargs):
|
def __new__(cls, *args, **kwargs):
|
||||||
|
@ -86,7 +83,8 @@ class BlockDevicesMockReturnNone:
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_block_devices_return_true(mocker):
|
def mock_block_devices_return_true(mocker):
|
||||||
mock = mocker.patch(
|
mock = mocker.patch(
|
||||||
"selfprivacy_api.utils.block_devices.BlockDevices",
|
"selfprivacy_api.graphql.mutations.storage_mutations.BlockDevices",
|
||||||
|
# "selfprivacy_api.utils.block_devices.BlockDevices",
|
||||||
autospec=True,
|
autospec=True,
|
||||||
return_value=BlockDevicesMockReturnTrue,
|
return_value=BlockDevicesMockReturnTrue,
|
||||||
)
|
)
|
||||||
|
@ -328,7 +326,7 @@ def test_graphql_unmount_volume_false(
|
||||||
assert response.json()["data"]["unmountVolume"]["success"] is False
|
assert response.json()["data"]["unmountVolume"]["success"] is False
|
||||||
|
|
||||||
|
|
||||||
def test_graphql_unmount_volume(authorized_client, mock_block_devices_return_none):
|
def test_graphql_unmount_volume(authorized_client, mock_block_devices_return_true):
|
||||||
response = authorized_client.post(
|
response = authorized_client.post(
|
||||||
"/graphql",
|
"/graphql",
|
||||||
json={
|
json={
|
||||||
|
|
|
@ -94,9 +94,7 @@ def test_graphql_remove_job(
|
||||||
json={
|
json={
|
||||||
"query": API_REMOVE_JOB_MUTATION,
|
"query": API_REMOVE_JOB_MUTATION,
|
||||||
"variables": {
|
"variables": {
|
||||||
"Job": {
|
"jobId": "12345",
|
||||||
"uid": "12345",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue