mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-07 10:56:49 +00:00
WIP: test the status pages (download is weird still; requests problem?)
This commit is contained in:
parent
ec70fa7090
commit
68e408118b
@ -157,3 +157,68 @@ def test_deep_stats(alice):
|
||||
else:
|
||||
print("{} != {}; waiting".format(d['size-literal-files'], len(FILE_CONTENTS)))
|
||||
time.sleep(.5)
|
||||
|
||||
|
||||
def test_status(alice):
|
||||
"""
|
||||
confirm we get something sensible from /status and the various sub-types
|
||||
"""
|
||||
# upload a file
|
||||
# (because of the nature of the integration-tests, we can only
|
||||
# assert things about "our" file because we don't know what other
|
||||
# operations may have happened in the grid before our test runs).
|
||||
FILE_CONTENTS = b"all the Important Data of alice\n" * 1000
|
||||
resp = requests.put(
|
||||
util.node_url(alice.node_dir, u"uri"),
|
||||
files={
|
||||
u"file": FILE_CONTENTS,
|
||||
},
|
||||
)
|
||||
cap = resp.text.strip()
|
||||
print("Uploaded data, cap={}".format(cap))
|
||||
resp = requests.get(
|
||||
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(resp.content[:120])
|
||||
assert resp.content == FILE_CONTENTS
|
||||
|
||||
# find our upload and download status pages
|
||||
from twisted.web import microdom
|
||||
from collections import defaultdict
|
||||
from twisted.web import microdom
|
||||
from collections import defaultdict
|
||||
|
||||
resp = requests.get(
|
||||
util.node_url(alice.node_dir, "status"),
|
||||
)
|
||||
dom = microdom.parseString(resp.content)
|
||||
|
||||
# so, we *could* descend the DOM "more properly" .. or just look
|
||||
# at the URIs
|
||||
hrefs = set()
|
||||
for td in dom.getElementsByTagName('td'):
|
||||
for link in dom.getElementsByTagName('a'):
|
||||
hrefs.add(link.getAttribute('href'))
|
||||
|
||||
found_our_status = False
|
||||
for href in hrefs:
|
||||
if href.startswith("/") or not href:
|
||||
continue
|
||||
resp = requests.get(
|
||||
util.node_url(alice.node_dir, u"status/{}".format(href)),
|
||||
)
|
||||
if href.startswith('up'):
|
||||
assert "File Upload Status" in resp.content
|
||||
if "Total Size: 32140" in resp.content:
|
||||
found_our_status = True
|
||||
elif href.startswith('down'):
|
||||
print(href)
|
||||
assert "File Download Status" in resp.content
|
||||
if "Total Size: 32140" in resp.content:
|
||||
print("FOUND IT\n\n\n")
|
||||
found_our_status = True
|
||||
|
||||
assert found_our_status, "Failed to find the file we uploaded in the status-page"
|
||||
|
Loading…
x
Reference in New Issue
Block a user