mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-22 12:11:26 +00:00
test(backups): preliminary test of repo reset
This commit is contained in:
parent
33c60f971d
commit
8e1e37c766
|
@ -64,7 +64,9 @@ class BackupMutations:
|
|||
def remove_repository(self) -> GenericBackupConfigReturn:
|
||||
"""Remove repository"""
|
||||
Backups.reset()
|
||||
return Backup.configuration()
|
||||
return GenericBackupConfigReturn(
|
||||
success=True, message="", code="200", configuration=Backup().configuration()
|
||||
)
|
||||
|
||||
@strawberry.mutation(permission_classes=[IsAuthenticated])
|
||||
def set_autobackup_period(
|
||||
|
|
|
@ -6,6 +6,24 @@ 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_REMOVE_REPOSITORY_MUTATION = """
|
||||
mutation TestRemoveRepo {
|
||||
removeRepository {
|
||||
success
|
||||
message
|
||||
code
|
||||
configuration {
|
||||
provider
|
||||
encryptionKey
|
||||
isInitialized
|
||||
autobackupPeriod
|
||||
locationName
|
||||
locationId
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
API_INIT_MUTATION = """
|
||||
mutation TestInitRepo($input: InitializeRepositoryInput!) {
|
||||
initializeRepository(repository: $input) {
|
||||
|
@ -85,6 +103,17 @@ def api_backup(authorized_client, service):
|
|||
return response
|
||||
|
||||
|
||||
def api_remove(authorized_client):
|
||||
response = authorized_client.post(
|
||||
"/graphql",
|
||||
json={
|
||||
"query": API_REMOVE_REPOSITORY_MUTATION,
|
||||
"variables": {},
|
||||
},
|
||||
)
|
||||
return response
|
||||
|
||||
|
||||
def api_init_without_key(
|
||||
authorized_client, kind, login, password, location_name, location_id
|
||||
):
|
||||
|
@ -193,3 +222,17 @@ def test_reinit(authorized_client, dummy_service, tmpdir):
|
|||
job = data["job"]
|
||||
|
||||
assert Jobs.get_job(job["uid"]).status == JobStatus.FINISHED
|
||||
|
||||
|
||||
def test_remove(authorized_client, generic_userdata):
|
||||
response = api_remove(authorized_client)
|
||||
data = get_data(response)["removeRepository"]
|
||||
assert_ok(data)
|
||||
|
||||
configuration = data["configuration"]
|
||||
assert configuration["provider"] == "BACKBLAZE"
|
||||
assert configuration["locationId"] == ""
|
||||
assert configuration["locationName"] == "selfprivacy"
|
||||
# still generated every time it is missing
|
||||
assert len(configuration["encryptionKey"]) > 1
|
||||
assert configuration["isInitialized"] is False
|
||||
|
|
Loading…
Reference in a new issue