Beispiel #1
0
 def test_explicitAllowedMethods(self):
     """
     The L{UnsupportedMethod} raised by L{Resource.render} for an unsupported
     request method has a C{allowedMethods} attribute set to the value of the
     C{allowedMethods} attribute of the L{Resource}, if it has one.
     """
     expected = [b'GET', b'HEAD', b'PUT']
     resource = Resource()
     resource.allowedMethods = expected
     request = DummyRequest([])
     request.method = b'FICTIONAL'
     exc = self.assertRaises(UnsupportedMethod, resource.render, request)
     self.assertEqual(set(expected), set(exc.allowedMethods))
Beispiel #2
0
 def test_explicitAllowedMethods(self):
     """
     The L{UnsupportedMethod} raised by L{Resource.render} for an unsupported
     request method has a C{allowedMethods} attribute set to the value of the
     C{allowedMethods} attribute of the L{Resource}, if it has one.
     """
     expected = [b"GET", b"HEAD", b"PUT"]
     resource = Resource()
     resource.allowedMethods = expected
     request = DummyRequest([])
     request.method = b"FICTIONAL"
     exc = self.assertRaises(UnsupportedMethod, resource.render, request)
     self.assertEqual(set(expected), set(exc.allowedMethods))
Beispiel #3
0
 def test_hasAllowedMethods(self):
     """
     Raise `UnsupportedErrors`, with the value of
     ``resource.allowedMethods``, if there are no matching renderers.
     """
     resource = Resource()
     request = InMemoryRequest([])
     request.method = b'PUT'
     resource.allowedMethods = [b'GET', b'HEAD']
     self.assertThat(
         partial(_renderResource, resource, request),
         MatchesException(
             UnsupportedMethod,
             MatchesStructure(
                 allowedMethods=MatchesSetwise(Equals('GET'),
                                               Equals('HEAD')))))