Skip to content

Commit

Permalink
Test - tidy up backup test (#2117)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtlmoon authored Jan 17, 2024
1 parent 36085d8 commit 9510345
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions changedetectionio/tests/test_backup.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

0 comments on commit 9510345

Please sign in to comment.