test(backups): ensure asking to reload snaps does not explode the server

This commit is contained in:
Houkime 2023-06-19 14:12:40 +00:00
parent 25f3115c05
commit e3a87f1d98
3 changed files with 49 additions and 3 deletions

View file

@ -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

View file

@ -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

View file

@ -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