mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-07 20:00:20 +00:00
Use BeautifulSoup in RenderSlashUri tests
This commit is contained in:
parent
136a70217c
commit
a413eb8626
@ -2,6 +2,8 @@ from mock import Mock
|
|||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
from twisted.web.template import Tag
|
from twisted.web.template import Tag
|
||||||
from twisted.web.test.requesthelper import DummyRequest
|
from twisted.web.test.requesthelper import DummyRequest
|
||||||
@ -19,6 +21,9 @@ from allmydata.client import _Client
|
|||||||
from hypothesis import given
|
from hypothesis import given
|
||||||
from hypothesis.strategies import text
|
from hypothesis.strategies import text
|
||||||
|
|
||||||
|
from .common import (
|
||||||
|
assert_soup_has_tag_with_content,
|
||||||
|
)
|
||||||
|
|
||||||
from ..common import (
|
from ..common import (
|
||||||
EMPTY_CLIENT_CONFIG,
|
EMPTY_CLIENT_CONFIG,
|
||||||
@ -58,14 +63,16 @@ class RenderSlashUri(unittest.TestCase):
|
|||||||
self.request.args[b"uri"] = [b"not a capability"]
|
self.request.args[b"uri"] = [b"not a capability"]
|
||||||
response_body = self.res.render_GET(self.request)
|
response_body = self.res.render_GET(self.request)
|
||||||
|
|
||||||
self.assertIn(
|
soup = BeautifulSoup(response_body, 'html5lib')
|
||||||
"<title>400 - Error</title>", response_body,
|
|
||||||
|
assert_soup_has_tag_with_content(
|
||||||
|
self, soup, "title", "400 - Error",
|
||||||
)
|
)
|
||||||
self.assertIn(
|
assert_soup_has_tag_with_content(
|
||||||
"<h1>Error</h1>", response_body,
|
self, soup, "h1", "Error",
|
||||||
)
|
)
|
||||||
self.assertIn(
|
assert_soup_has_tag_with_content(
|
||||||
"<p>Invalid capability</p>", response_body,
|
self, soup, "p", "Invalid capability",
|
||||||
)
|
)
|
||||||
|
|
||||||
@given(
|
@given(
|
||||||
@ -78,14 +85,16 @@ class RenderSlashUri(unittest.TestCase):
|
|||||||
self.request.args[b"uri"] = [cap.encode('utf8')]
|
self.request.args[b"uri"] = [cap.encode('utf8')]
|
||||||
response_body = self.res.render_GET(self.request)
|
response_body = self.res.render_GET(self.request)
|
||||||
|
|
||||||
self.assertIn(
|
soup = BeautifulSoup(response_body, 'html5lib')
|
||||||
"<title>400 - Error</title>", response_body,
|
|
||||||
|
assert_soup_has_tag_with_content(
|
||||||
|
self, soup, "title", "400 - Error",
|
||||||
)
|
)
|
||||||
self.assertIn(
|
assert_soup_has_tag_with_content(
|
||||||
"<h1>Error</h1>", response_body,
|
self, soup, "h1", "Error",
|
||||||
)
|
)
|
||||||
self.assertIn(
|
assert_soup_has_tag_with_content(
|
||||||
"<p>Invalid capability</p>", response_body,
|
self, soup, "p", "Invalid capability",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user