mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-03-11 00:59:06 +00:00
test(backups): ensure asking to reload snaps does not explode the server
This commit is contained in:
parent
ecf72948b1
commit
53dfb38284
3 changed files with 49 additions and 3 deletions
|
@ -21,7 +21,7 @@ class AbstractBackuper(ABC):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_snapshots(self, repo_name) -> List[Snapshot]:
|
def get_snapshots(self) -> List[Snapshot]:
|
||||||
"""Get all snapshots from the repo"""
|
"""Get all snapshots from the repo"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,9 @@ class NoneBackupper(AbstractBackuper):
|
||||||
def start_backup(self, folders: List[str], repo_name: str):
|
def start_backup(self, folders: List[str], repo_name: str):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def get_snapshots(self, repo_name) -> List[Snapshot]:
|
def get_snapshots(self) -> List[Snapshot]:
|
||||||
"""Get all snapshots from the repo"""
|
"""Get all snapshots from the repo"""
|
||||||
raise NotImplementedError
|
return []
|
||||||
|
|
||||||
def init(self, repo_name):
|
def init(self, repo_name):
|
||||||
raise NotImplementedError
|
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.graphql.common_types.service import service_to_graphql_service
|
||||||
from selfprivacy_api.jobs import Jobs, JobStatus
|
from selfprivacy_api.jobs import Jobs, JobStatus
|
||||||
|
|
||||||
|
API_RELOAD_SNAPSHOTS = """
|
||||||
|
mutation TestSnapshotsReload {
|
||||||
|
forceSnapshotsReload {
|
||||||
|
success
|
||||||
|
message
|
||||||
|
code
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
API_SET_AUTOBACKUP_PERIOD_MUTATION = """
|
API_SET_AUTOBACKUP_PERIOD_MUTATION = """
|
||||||
mutation TestAutobackupPeriod($period: Int) {
|
mutation TestAutobackupPeriod($period: Int) {
|
||||||
setAutobackupPeriod(period: $period) {
|
setAutobackupPeriod(period: $period) {
|
||||||
|
@ -143,6 +153,17 @@ def api_remove(authorized_client):
|
||||||
return response
|
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(
|
def api_init_without_key(
|
||||||
authorized_client, kind, login, password, location_name, location_id
|
authorized_client, kind, login, password, location_name, location_id
|
||||||
):
|
):
|
||||||
|
@ -312,3 +333,28 @@ def test_autobackup_period_negative(authorized_client):
|
||||||
|
|
||||||
configuration = data["configuration"]
|
configuration = data["configuration"]
|
||||||
assert configuration["autobackupPeriod"] == None
|
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…
Add table
Reference in a new issue