mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-27 14:30:19 +00:00
refine test for web status
This commit is contained in:
parent
73402605ed
commit
c60c758616
@ -163,26 +163,26 @@ def test_status(alice):
|
|||||||
"""
|
"""
|
||||||
confirm we get something sensible from /status and the various sub-types
|
confirm we get something sensible from /status and the various sub-types
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# upload a file
|
# upload a file
|
||||||
# (because of the nature of the integration-tests, we can only
|
# (because of the nature of the integration-tests, we can only
|
||||||
# assert things about "our" file because we don't know what other
|
# assert things about "our" file because we don't know what other
|
||||||
# operations may have happened in the grid before our test runs).
|
# operations may have happened in the grid before our test runs).
|
||||||
FILE_CONTENTS = b"all the Important Data of alice\n" * 1000
|
|
||||||
|
FILE_CONTENTS = b"all the Important Data of alice\n" * 1200
|
||||||
|
|
||||||
resp = requests.put(
|
resp = requests.put(
|
||||||
util.node_url(alice.node_dir, u"uri"),
|
util.node_url(alice.node_dir, u"uri"),
|
||||||
files={
|
data=FILE_CONTENTS,
|
||||||
u"file": FILE_CONTENTS,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
cap = resp.text.strip()
|
cap = resp.text.strip()
|
||||||
|
|
||||||
print("Uploaded data, cap={}".format(cap))
|
print("Uploaded data, cap={}".format(cap))
|
||||||
resp = requests.get(
|
resp = requests.get(
|
||||||
util.node_url(alice.node_dir, u"uri/{}".format(urllib2.quote(cap))),
|
util.node_url(alice.node_dir, u"uri/{}".format(urllib2.quote(cap))),
|
||||||
)
|
)
|
||||||
print("Downloaded {} bytes of data".format(len(resp.content)))
|
|
||||||
|
|
||||||
print(dir(resp))
|
print("Downloaded {} bytes of data".format(len(resp.content)))
|
||||||
print(resp.content[:120])
|
|
||||||
assert resp.content == FILE_CONTENTS
|
assert resp.content == FILE_CONTENTS
|
||||||
|
|
||||||
# find our upload and download status pages
|
# find our upload and download status pages
|
||||||
@ -203,22 +203,24 @@ def test_status(alice):
|
|||||||
for link in dom.getElementsByTagName('a'):
|
for link in dom.getElementsByTagName('a'):
|
||||||
hrefs.add(link.getAttribute('href'))
|
hrefs.add(link.getAttribute('href'))
|
||||||
|
|
||||||
found_our_status = False
|
found_upload = False
|
||||||
|
found_download = False
|
||||||
for href in hrefs:
|
for href in hrefs:
|
||||||
if href.startswith("/") or not href:
|
print("href: {}".format(href))
|
||||||
|
if href.startswith(u"/") or not href:
|
||||||
continue
|
continue
|
||||||
resp = requests.get(
|
resp = requests.get(
|
||||||
util.node_url(alice.node_dir, u"status/{}".format(href)),
|
util.node_url(alice.node_dir, u"status/{}".format(href)),
|
||||||
)
|
)
|
||||||
if href.startswith('up'):
|
if href.startswith(u'up'):
|
||||||
assert "File Upload Status" in resp.content
|
assert "File Upload Status" in resp.content
|
||||||
if "Total Size: 32140" in resp.content:
|
if "Total Size: {}".format(len(FILE_CONTENTS)) in resp.content:
|
||||||
found_our_status = True
|
found_upload = True
|
||||||
elif href.startswith('down'):
|
elif href.startswith(u'down'):
|
||||||
print(href)
|
print(href)
|
||||||
assert "File Download Status" in resp.content
|
assert "File Download Status" in resp.content
|
||||||
if "Total Size: 32140" in resp.content:
|
if "Total Size: {}".format(len(FILE_CONTENTS)) in resp.content:
|
||||||
print("FOUND IT\n\n\n")
|
found_download = True
|
||||||
found_our_status = True
|
|
||||||
|
|
||||||
assert found_our_status, "Failed to find the file we uploaded in the status-page"
|
assert found_upload, "Failed to find the file we uploaded in the status-page"
|
||||||
|
assert found_download, "Failed to find the file we downloaded in the status-page"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user