kopia lustrzana https://github.com/dgtlmoon/changedetection.io
Test - tidy up backup test (#2117)
rodzic
36085d8cf4
commit
9510345e01
|
@ -1,8 +1,8 @@
|
||||||
#!/usr/bin/python3
|
#!/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 flask import url_for
|
||||||
from urllib.request import urlopen
|
import io
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
@ -37,15 +37,10 @@ def test_backup(client, live_server):
|
||||||
# Should be PK/ZIP stream
|
# Should be PK/ZIP stream
|
||||||
assert res.data.count(b'PK') >= 2
|
assert res.data.count(b'PK') >= 2
|
||||||
|
|
||||||
# ZipFile from buffer seems non-obvious, just save it instead
|
backup = ZipFile(io.BytesIO(res.data))
|
||||||
with open("download.zip", 'wb') as f:
|
l = backup.namelist()
|
||||||
f.write(res.data)
|
|
||||||
|
|
||||||
zip = ZipFile('download.zip')
|
|
||||||
l = zip.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)
|
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
|
newlist = list(filter(uuid4hex.match, l)) # Read Note below
|
||||||
|
|
||||||
# Should be two txt files in the archive (history and the snapshot)
|
# Should be two txt files in the archive (history and the snapshot)
|
||||||
assert len(newlist) == 2
|
assert len(newlist) == 2
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue