Fix the URL in the URL preview tests

the preview resource is mointed at preview_url, not url_preview
This commit is contained in:
Richard van der Hoff 2020-11-14 01:29:16 +00:00
parent 3dc1871219
commit 1f41422c98

View File

@ -133,11 +133,14 @@ class URLPreviewTests(unittest.HomeserverTestCase):
self.reactor.nameResolver = Resolver() self.reactor.nameResolver = Resolver()
def create_test_resource(self):
return self.hs.get_media_repository_resource()
def test_cache_returns_correct_type(self): def test_cache_returns_correct_type(self):
self.lookups["matrix.org"] = [(IPv4Address, "10.1.2.3")] self.lookups["matrix.org"] = [(IPv4Address, "10.1.2.3")]
request, channel = self.make_request( request, channel = self.make_request(
"GET", "url_preview?url=http://matrix.org", shorthand=False "GET", "preview_url?url=http://matrix.org", shorthand=False,
) )
request.render(self.preview_url) request.render(self.preview_url)
self.pump() self.pump()
@ -160,7 +163,7 @@ class URLPreviewTests(unittest.HomeserverTestCase):
# Check the cache returns the correct response # Check the cache returns the correct response
request, channel = self.make_request( request, channel = self.make_request(
"GET", "url_preview?url=http://matrix.org", shorthand=False "GET", "preview_url?url=http://matrix.org", shorthand=False
) )
request.render(self.preview_url) request.render(self.preview_url)
self.pump() self.pump()
@ -178,7 +181,7 @@ class URLPreviewTests(unittest.HomeserverTestCase):
# Check the database cache returns the correct response # Check the database cache returns the correct response
request, channel = self.make_request( request, channel = self.make_request(
"GET", "url_preview?url=http://matrix.org", shorthand=False "GET", "preview_url?url=http://matrix.org", shorthand=False
) )
request.render(self.preview_url) request.render(self.preview_url)
self.pump() self.pump()
@ -201,7 +204,7 @@ class URLPreviewTests(unittest.HomeserverTestCase):
) )
request, channel = self.make_request( request, channel = self.make_request(
"GET", "url_preview?url=http://matrix.org", shorthand=False "GET", "preview_url?url=http://matrix.org", shorthand=False,
) )
request.render(self.preview_url) request.render(self.preview_url)
self.pump() self.pump()
@ -234,7 +237,7 @@ class URLPreviewTests(unittest.HomeserverTestCase):
) )
request, channel = self.make_request( request, channel = self.make_request(
"GET", "url_preview?url=http://matrix.org", shorthand=False "GET", "preview_url?url=http://matrix.org", shorthand=False
) )
request.render(self.preview_url) request.render(self.preview_url)
self.pump() self.pump()
@ -267,7 +270,7 @@ class URLPreviewTests(unittest.HomeserverTestCase):
) )
request, channel = self.make_request( request, channel = self.make_request(
"GET", "url_preview?url=http://matrix.org", shorthand=False "GET", "preview_url?url=http://matrix.org", shorthand=False
) )
request.render(self.preview_url) request.render(self.preview_url)
self.pump() self.pump()
@ -298,7 +301,7 @@ class URLPreviewTests(unittest.HomeserverTestCase):
self.lookups["example.com"] = [(IPv4Address, "10.1.2.3")] self.lookups["example.com"] = [(IPv4Address, "10.1.2.3")]
request, channel = self.make_request( request, channel = self.make_request(
"GET", "url_preview?url=http://example.com", shorthand=False "GET", "preview_url?url=http://example.com", shorthand=False
) )
request.render(self.preview_url) request.render(self.preview_url)
self.pump() self.pump()
@ -326,7 +329,7 @@ class URLPreviewTests(unittest.HomeserverTestCase):
self.lookups["example.com"] = [(IPv4Address, "192.168.1.1")] self.lookups["example.com"] = [(IPv4Address, "192.168.1.1")]
request, channel = self.make_request( request, channel = self.make_request(
"GET", "url_preview?url=http://example.com", shorthand=False "GET", "preview_url?url=http://example.com", shorthand=False
) )
request.render(self.preview_url) request.render(self.preview_url)
self.pump() self.pump()
@ -349,7 +352,7 @@ class URLPreviewTests(unittest.HomeserverTestCase):
self.lookups["example.com"] = [(IPv4Address, "1.1.1.2")] self.lookups["example.com"] = [(IPv4Address, "1.1.1.2")]
request, channel = self.make_request( request, channel = self.make_request(
"GET", "url_preview?url=http://example.com", shorthand=False "GET", "preview_url?url=http://example.com", shorthand=False
) )
request.render(self.preview_url) request.render(self.preview_url)
self.pump() self.pump()
@ -368,7 +371,7 @@ class URLPreviewTests(unittest.HomeserverTestCase):
Blacklisted IP addresses, accessed directly, are not spidered. Blacklisted IP addresses, accessed directly, are not spidered.
""" """
request, channel = self.make_request( request, channel = self.make_request(
"GET", "url_preview?url=http://192.168.1.1", shorthand=False "GET", "preview_url?url=http://192.168.1.1", shorthand=False
) )
request.render(self.preview_url) request.render(self.preview_url)
self.pump() self.pump()
@ -389,7 +392,7 @@ class URLPreviewTests(unittest.HomeserverTestCase):
Blacklisted IP ranges, accessed directly, are not spidered. Blacklisted IP ranges, accessed directly, are not spidered.
""" """
request, channel = self.make_request( request, channel = self.make_request(
"GET", "url_preview?url=http://1.1.1.2", shorthand=False "GET", "preview_url?url=http://1.1.1.2", shorthand=False
) )
request.render(self.preview_url) request.render(self.preview_url)
self.pump() self.pump()
@ -411,7 +414,7 @@ class URLPreviewTests(unittest.HomeserverTestCase):
self.lookups["example.com"] = [(IPv4Address, "1.1.1.1")] self.lookups["example.com"] = [(IPv4Address, "1.1.1.1")]
request, channel = self.make_request( request, channel = self.make_request(
"GET", "url_preview?url=http://example.com", shorthand=False "GET", "preview_url?url=http://example.com", shorthand=False
) )
request.render(self.preview_url) request.render(self.preview_url)
self.pump() self.pump()
@ -446,7 +449,7 @@ class URLPreviewTests(unittest.HomeserverTestCase):
] ]
request, channel = self.make_request( request, channel = self.make_request(
"GET", "url_preview?url=http://example.com", shorthand=False "GET", "preview_url?url=http://example.com", shorthand=False
) )
request.render(self.preview_url) request.render(self.preview_url)
self.pump() self.pump()
@ -468,7 +471,7 @@ class URLPreviewTests(unittest.HomeserverTestCase):
] ]
request, channel = self.make_request( request, channel = self.make_request(
"GET", "url_preview?url=http://example.com", shorthand=False "GET", "preview_url?url=http://example.com", shorthand=False
) )
request.render(self.preview_url) request.render(self.preview_url)
self.pump() self.pump()
@ -491,7 +494,7 @@ class URLPreviewTests(unittest.HomeserverTestCase):
self.lookups["example.com"] = [(IPv6Address, "2001:800::1")] self.lookups["example.com"] = [(IPv6Address, "2001:800::1")]
request, channel = self.make_request( request, channel = self.make_request(
"GET", "url_preview?url=http://example.com", shorthand=False "GET", "preview_url?url=http://example.com", shorthand=False
) )
request.render(self.preview_url) request.render(self.preview_url)
self.pump() self.pump()
@ -510,7 +513,7 @@ class URLPreviewTests(unittest.HomeserverTestCase):
OPTIONS returns the OPTIONS. OPTIONS returns the OPTIONS.
""" """
request, channel = self.make_request( request, channel = self.make_request(
"OPTIONS", "url_preview?url=http://example.com", shorthand=False "OPTIONS", "preview_url?url=http://example.com", shorthand=False
) )
request.render(self.preview_url) request.render(self.preview_url)
self.pump() self.pump()
@ -525,7 +528,7 @@ class URLPreviewTests(unittest.HomeserverTestCase):
# Build and make a request to the server # Build and make a request to the server
request, channel = self.make_request( request, channel = self.make_request(
"GET", "url_preview?url=http://example.com", shorthand=False "GET", "preview_url?url=http://example.com", shorthand=False
) )
request.render(self.preview_url) request.render(self.preview_url)
self.pump() self.pump()
@ -598,7 +601,7 @@ class URLPreviewTests(unittest.HomeserverTestCase):
request, channel = self.make_request( request, channel = self.make_request(
"GET", "GET",
"url_preview?url=http://twitter.com/matrixdotorg/status/12345", "preview_url?url=http://twitter.com/matrixdotorg/status/12345",
shorthand=False, shorthand=False,
) )
request.render(self.preview_url) request.render(self.preview_url)
@ -663,7 +666,7 @@ class URLPreviewTests(unittest.HomeserverTestCase):
request, channel = self.make_request( request, channel = self.make_request(
"GET", "GET",
"url_preview?url=http://twitter.com/matrixdotorg/status/12345", "preview_url?url=http://twitter.com/matrixdotorg/status/12345",
shorthand=False, shorthand=False,
) )
request.render(self.preview_url) request.render(self.preview_url)