' % len(self.BAR_CONTENTS),
- ])
- self.failUnless(re.search(get_bar, res), res)
- for label in ['unlink', 'rename/relink']:
- for line in res.split("\n"):
- # find the line that contains the relevant button for bar.txt
- if ("form action" in line and
- ('value="%s"' % (label,)) in line and
- 'value="bar.txt"' in line):
- # the form target should use a relative URL
- foo_url = urllib.quote("%s/uri/%s/" % (ROOT, self._foo_uri))
- self.failUnlessIn('action="%s"' % foo_url, line)
- # and the when_done= should too
- #done_url = urllib.quote(???)
- #self.failUnlessIn('name="when_done" value="%s"' % done_url, line)
+ # the FILE reference points to a URI, but it should end in bar.txt
+ bar_url = "{}/file/{}/@@named=/bar.txt".format(root, urllib.quote(self._bar_txt_uri))
+ self.assertTrue(
+ any(
+ a.text == u"bar.txt"
+ for a in soup.find_all(u"a", {u"href": bar_url})
+ )
+ )
+ self.assertTrue(
+ any(
+ td.text == u"{}".format(len(self.BAR_CONTENTS))
+ for td in soup.find_all(u"td", {u"align": u"right"})
+ )
+ )
+ foo_url = urllib.quote("{}/uri/{}/".format(root, self._foo_uri))
+ forms = soup.find_all(u"form", {u"action": foo_url})
+ found = []
+ for form in forms:
+ if form.find_all(u"input", {u"name": u"name", u"value": u"bar.txt"}):
+ kind = form.find_all(u"input", {u"type": u"submit"})[0][u"value"]
+ found.append(kind)
+ if kind == u"unlink":
+ self.assertTrue(form[u"method"] == u"post")
+ self.assertEqual(
+ set(found),
+ {u"unlink", u"rename/relink"}
+ )
- # 'unlink' needs to use POST because it directly has a side effect
- if label == 'unlink':
- self.failUnlessIn('method="post"', line)
- break
- else:
- self.fail("unable to find '%s bar.txt' line" % (label,))
-
- # the DIR reference just points to a URI
- sub_url = ("%s/uri/%s/" % (ROOT, urllib.quote(self._sub_uri)))
- get_sub = ((r'