Test - tidy up backup test (#2117)

pull/2119/head
dgtlmoon 11 months ago committed by GitHub
parent 36085d8cf4
commit 9510345e01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,8 +1,8 @@
#!/usr/bin/python3
from .util import set_original_response, set_modified_response, live_server_setup, wait_for_all_checks
from .util import set_original_response, live_server_setup, wait_for_all_checks
from flask import url_for
from urllib.request import urlopen
import io
from zipfile import ZipFile
import re
import time
@ -37,15 +37,10 @@ def test_backup(client, live_server):
# Should be PK/ZIP stream
assert res.data.count(b'PK') >= 2
# ZipFile from buffer seems non-obvious, just save it instead
with open("download.zip", 'wb') as f:
f.write(res.data)
zip = ZipFile('download.zip')
l = zip.namelist()
backup = ZipFile(io.BytesIO(res.data))
l = backup.namelist()
uuid4hex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}.*txt', re.I)
newlist = list(filter(uuid4hex.match, l)) # Read Note below
# Should be two txt files in the archive (history and the snapshot)
assert len(newlist) == 2

Loading…
Cancel
Save