mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-22 04:01:27 +00:00
test(backups): ensure asking to reload snaps does not explode the server
This commit is contained in:
parent
25f3115c05
commit
e3a87f1d98
|
@ -21,7 +21,7 @@ class AbstractBackuper(ABC):
|
|||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def get_snapshots(self, repo_name) -> List[Snapshot]:
|
||||
def get_snapshots(self) -> List[Snapshot]:
|
||||
"""Get all snapshots from the repo"""
|
||||
raise NotImplementedError
|
||||
|
||||
|
|
|
@ -14,9 +14,9 @@ class NoneBackupper(AbstractBackuper):
|
|||
def start_backup(self, folders: List[str], repo_name: str):
|
||||
raise NotImplementedError
|
||||
|
||||
def get_snapshots(self, repo_name) -> List[Snapshot]:
|
||||
def get_snapshots(self) -> List[Snapshot]:
|
||||
"""Get all snapshots from the repo"""
|
||||
raise NotImplementedError
|
||||
return []
|
||||
|
||||
def init(self, repo_name):
|
||||
raise NotImplementedError
|
||||
|
|
|
@ -6,6 +6,16 @@ from tests.common import generate_backup_query
|
|||
from selfprivacy_api.graphql.common_types.service import service_to_graphql_service
|
||||
from selfprivacy_api.jobs import Jobs, JobStatus
|
||||
|
||||
API_RELOAD_SNAPSHOTS = """
|
||||
mutation TestSnapshotsReload {
|
||||
forceSnapshotsReload {
|
||||
success
|
||||
message
|
||||
code
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
API_SET_AUTOBACKUP_PERIOD_MUTATION = """
|
||||
mutation TestAutobackupPeriod($period: Int) {
|
||||
setAutobackupPeriod(period: $period) {
|
||||
|
@ -143,6 +153,17 @@ def api_remove(authorized_client):
|
|||
return response
|
||||
|
||||
|
||||
def api_reload_snapshots(authorized_client):
|
||||
response = authorized_client.post(
|
||||
"/graphql",
|
||||
json={
|
||||
"query": API_RELOAD_SNAPSHOTS,
|
||||
"variables": {},
|
||||
},
|
||||
)
|
||||
return response
|
||||
|
||||
|
||||
def api_init_without_key(
|
||||
authorized_client, kind, login, password, location_name, location_id
|
||||
):
|
||||
|
@ -312,3 +333,28 @@ def test_autobackup_period_negative(authorized_client):
|
|||
|
||||
configuration = data["configuration"]
|
||||
assert configuration["autobackupPeriod"] == None
|
||||
|
||||
|
||||
# We cannot really check the effect at this level, we leave it to backend tests
|
||||
# But we still make it run in both empty and full scenarios and ask for snaps afterwards
|
||||
def test_reload_snapshots_bare_bare_bare(authorized_client, dummy_service):
|
||||
api_remove(authorized_client)
|
||||
|
||||
response = api_reload_snapshots(authorized_client)
|
||||
data = get_data(response)["forceSnapshotsReload"]
|
||||
assert_ok(data)
|
||||
|
||||
snaps = api_snapshots(authorized_client)
|
||||
assert snaps == []
|
||||
|
||||
|
||||
def test_reload_snapshots(authorized_client, dummy_service):
|
||||
response = api_backup(authorized_client, dummy_service)
|
||||
data = get_data(response)["startBackup"]
|
||||
|
||||
response = api_reload_snapshots(authorized_client)
|
||||
data = get_data(response)["forceSnapshotsReload"]
|
||||
assert_ok(data)
|
||||
|
||||
snaps = api_snapshots(authorized_client)
|
||||
assert len(snaps) == 1
|
||||
|
|
Loading…
Reference in a new issue