Skip to content

Commit 9510345

Browse files
authored
Test - tidy up backup test (#2117)
1 parent 36085d8 commit 9510345

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

changedetectionio/tests/test_backup.py

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/python3
22

3-
from .util import set_original_response, set_modified_response, live_server_setup, wait_for_all_checks
3+
from .util import set_original_response, live_server_setup, wait_for_all_checks
44
from flask import url_for
5-
from urllib.request import urlopen
5+
import io
66
from zipfile import ZipFile
77
import re
88
import time
@@ -37,15 +37,10 @@ def test_backup(client, live_server):
3737
# Should be PK/ZIP stream
3838
assert res.data.count(b'PK') >= 2
3939

40-
# ZipFile from buffer seems non-obvious, just save it instead
41-
with open("download.zip", 'wb') as f:
42-
f.write(res.data)
43-
44-
zip = ZipFile('download.zip')
45-
l = zip.namelist()
40+
backup = ZipFile(io.BytesIO(res.data))
41+
l = backup.namelist()
4642
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)
4743
newlist = list(filter(uuid4hex.match, l)) # Read Note below
4844

4945
# Should be two txt files in the archive (history and the snapshot)
5046
assert len(newlist) == 2
51-

0 commit comments

Comments
 (0)