Beispiel #1
0
 def test_checkRegisteredMappers(self):
     """
     Fetch mapper resource at different levels.
     """
     proc = Processor(self.env)
     # root level
     data = proc.run(GET, '/')
     self.assertTrue('mapper-test' in data.keys())
     self.assertTrue('testmapping4' in data.keys())
     # virtual level
     proc = Processor(self.env)
     data = proc.run(GET, '/mapper-test')
     # registered mappers
     self.assertTrue('testmapping' in data.keys())
     self.assertTrue('testmapping2' in data.keys())
     self.assertTrue('testmapping3' in data.keys())
     # unregistered mapper
     self.assertFalse('testmapping5' in data.keys())
     # content
     proc = Processor(self.env)
     data = proc.run(GET, '/mapper-test/testmapping')
     self.assertEqual(data, 'muh')
     # HEAD equals GET
     data = proc.run(HEAD, '/testmapping4')
     self.assertEquals(data, 'MÜH')
Beispiel #2
0
 def test_processResourceType(self):
     proc = Processor(self.env)
     proc.path = '/xml/processor-test/notvc'
     # test valid GET method
     data = proc.run(GET, '/xml/processor-test/notvc/.meta')
     # data must be a dict
     self.assertTrue(isinstance(data, dict))
     # test valid POST method
     data = proc.run(POST, '/xml/processor-test/notvc', StringIO(XML_DOC))
     # check response; data should be empty; we look into request
     self.assertFalse(data)
     self.assertEqual(proc.code, http.CREATED)
     self.assertTrue(isinstance(proc.headers, dict))
     self.assertTrue('Location' in proc.headers)
     location = proc.headers.get('Location')
     self.assertTrue(location.startswith(self.env.getRestUrl() + proc.path))
     # strip REST url from location
     location = location[len(self.env.getRestUrl()):]
     # fetch resource and compare it with original
     data = proc.run(GET, location)
     self.assertTrue(data, XML_DOC)
     # delete uploaded resource
     data = proc.run(DELETE, location)
     # check response; data should be empty; we look into request
     self.assertFalse(data)
     self.assertEqual(proc.code, http.NO_CONTENT)
Beispiel #3
0
 def test_strangeRequestPatterns(self):
     """
     Test strange request patterns.
     """
     proc = Processor(self.env)
     # root
     data = proc.run(GET, '///')
     self.assertTrue('xml' in data)
     data = proc.run(GET, '//./')
     self.assertTrue('xml' in data)
     # results in /xml
     data = proc.run(GET, '/xml//')
     self.assertTrue('seishub' in data)
     data = proc.run(GET, '//xml/')
     self.assertTrue('seishub' in data)
     data = proc.run(GET, '//////////////////////xml//////////////')
     self.assertTrue('seishub' in data)
     data = proc.run(GET, '/////////./////////////xml///////.////.///')
     self.assertTrue('seishub' in data)
     # results in /xml/seishub
     data = proc.run(GET, '//////////////////////xml/////////////seishub/')
     self.assertTrue('schema' in data)
     data = proc.run(GET, '/////////////////xml///////.//////seishub////')
     self.assertTrue('schema' in data)
     data = proc.run(GET, '/////////////////xml/../xml////seishub////')
     self.assertTrue('schema' in data)
Beispiel #4
0
 def test_processResource(self):
     proc = Processor(self.env)
     # upload a resource via POST
     data = proc.run(POST, '/xml/processor-test/notvc', StringIO(XML_DOC))
     # check response; data should be empty; we look into request
     self.assertFalse(data)
     self.assertEqual(proc.code, http.CREATED)
     self.assertTrue(isinstance(proc.headers, dict))
     self.assertTrue('Location' in proc.headers)
     location = proc.headers.get('Location')
     self.assertTrue(location.startswith(self.env.getRestUrl() + proc.path))
     # GET resource
     location = location[len(self.env.getRestUrl()):]
     data = proc.run(GET, location).render_GET(proc)
     self.assertEquals(data, XML_DOC)
     # overwrite this resource via PUT request
     proc.run(PUT, location, StringIO(XML_DOC2))
     # GET resource
     data = proc.run(GET, location).render_GET(proc)
     self.assertNotEquals(data, XML_DOC)
     self.assertEquals(data, XML_DOC2)
     # DELETE resource
     proc.run(DELETE, location)
     # GET deleted revision
     try:
         proc.run(GET, location).render_GET(proc)
         self.fail("Expected SeisHubError")
     except SeisHubError, e:
         self.assertEqual(e.code, http.NOT_FOUND)
 def test_moveToNewResource(self):
     """
     Resource was moved successfully to the specified destination URI.
     """
     proc = Processor(self.env)
     # create resource
     proc.run(POST, '/move-test/notvc/test.xml', StringIO(XML_DOC))
     # move
     uri = self.env.getRestUrl() + '/move-test/notvc/new.xml'
     data = proc.run(MOVE,
                     '/move-test/notvc/test.xml',
                     received_headers={'Destination': uri})
     # test if right response code
     self.assertFalse(data)
     self.assertEqual(proc.code, http.CREATED)
     # test if location header is set
     self.assertTrue(isinstance(proc.headers, dict))
     self.assertTrue('Location' in proc.headers)
     location = proc.headers.get('Location')
     self.assertEquals(location, uri)
     # get original resource
     try:
         proc.run(GET, '/move-test/notvc/test.xml').render_GET(proc)
         self.fail("Expected SeisHubError")
     except SeisHubError, e:
         self.assertEqual(e.code, http.NOT_FOUND)
 def test_postJapaneseXMLDocuments(self):
     """
     Part of the W3C XML conformance test suite.
     
     This covers tests with different encoding and byte orders, e.g. UTF-16 
     with big and little endian. 
     
     @see: L{http://www.w3.org/XML/Test/}.
     """
     proc = Processor(self.env)
     path = os.path.dirname(__file__)
     # read all files
     files = glob.glob(os.path.join(path, 'data', 'japanese', '*.xml'))
     for file in files:
         # create resource
         data = open(file, 'rb').read()
         # first PUT should be handled as POST
         proc.run(POST, '/post-test/notvc/test.xml', StringIO(data))
         # overwrite resource
         proc.run(PUT, '/post-test/notvc/test.xml', StringIO(data))
         # delete resource
         proc.run(DELETE, '/post-test/notvc/test.xml')
     # same as before but using only PUT
     for file in files:
         # create resource
         data = open(file, 'rb').read()
         # first PUT should be handled as POST
         proc.run(PUT, '/post-test/notvc/test.xml', StringIO(data))
         # overwrite resource
         proc.run(PUT, '/post-test/notvc/test.xml', StringIO(data))
         # delete resource
         proc.run(DELETE, '/post-test/notvc/test.xml')
Beispiel #7
0
 def test_getRoot(self):
     proc = Processor(self.env)
     data = proc.run(GET, '/')
     # data must be a dict
     self.assertTrue(isinstance(data, dict))
     # check content
     self.assertTrue('xml' in data.keys())
 def test_getRevisionFromNotVersionControlledResource(self):
     proc = Processor(self.env)
     # create resource
     proc.run(POST, '/get-test/notvc/test.xml', StringIO(XML_DOC))
     proc.run(PUT, '/get-test/notvc/test.xml', StringIO(XML_DOC))
     proc.run(PUT, '/get-test/notvc/test.xml', StringIO(XML_DOC))
     # revision #1 always exist
     # without trailing slash
     res1 = proc.run(GET, '/get-test/notvc/test.xml/1')
     data1 = res1.render(proc)
     # with trailing slash
     res2 = proc.run(GET, '/get-test/notvc/test.xml/1/')
     data2 = res2.render(proc)
     # res must be RESTResource objects
     self.assertTrue(isinstance(res1, RESTResource))
     self.assertTrue(isinstance(res2, RESTResource))
     # both results should equal
     self.assertTrue(Set(data1) == Set(data2))
     # data must be a basestring
     self.assertTrue(isinstance(data1, basestring))
     # check content
     self.assertEquals(data1, XML_DOC)
     # try to GET revision 2
     try:
         proc.run(GET, '/get-test/notvc/test.xml/2')
     except SeisHubError, e:
         self.assertEqual(e.code, http.NOT_FOUND)
 def test_getResourceIndexWithMultipleValuesAndGroupElement(self):
     """
     Tests resource index property.
     """
     proc = Processor(self.env)
     # create resource
     XML_DOC = XML_BASE_DOC2 % ("<v>1</v><v>2</v><v>3</v><u>-1</u><u>5</u>",
                                "<v>10</v><v>20</v><v>30</v>" + \
                                "<u>-10</u><u>-20</u>")
     proc.run(POST, '/property-test/notvc4/test.xml', StringIO(XML_DOC))
     # get data
     res = proc.run(GET, '/property-test/notvc4/test.xml')
     res.render_GET(proc)
     # get index
     res = proc.run(GET, '/property-test/notvc4/test.xml/.index')
     data = res.render_GET(proc)
     self.assertTrue("<label4>" in data)
     self.assertTrue("<value>1</value>" in data)
     self.assertTrue("<value>2</value>" in data)
     self.assertTrue("<value>3</value>" in data)
     self.assertTrue("<value>10</value>" in data)
     self.assertTrue("<value>20</value>" in data)
     self.assertTrue("<value>30</value>" in data)
     # remove resource
     proc.run(DELETE, '/property-test/notvc4/test.xml')
Beispiel #10
0
 def test_getVersionControlledResourceTypeFolder(self):
     """
     Get content of a version controlled resource type folder.
     """
     proc = Processor(self.env)
     # create resource
     proc.run(POST, '/get-test/vc/test.xml', StringIO(XML_DOC2 % 11111))
     proc.run(PUT, '/get-test/vc/test.xml', StringIO(XML_DOC2 % 22222))
     proc.run(PUT, '/get-test/vc/test.xml', StringIO(XML_DOC2 % 33333))
     proc.run(POST, '/get-test/vc/test2.xml', StringIO(XML_DOC2 % 44444))
     proc.run(PUT, '/get-test/vc/test2.xml', StringIO(XML_DOC2 % 55555))
     # without trailing slash
     data = proc.run(GET, '/get-test/vc/.meta')
     # data must be a dict
     self.assertTrue(isinstance(data, dict))
     # check folder content
     self.assertTrue('test.xml' in data)
     self.assertTrue('test2.xml' in data)
     # get revisions
     res1 = proc.run(GET, '/get-test/vc/test.xml')
     data1 = res1.render(proc)
     res2 = proc.run(GET, '/get-test/vc/test2.xml')
     data2 = res2.render(proc)
     # check revisions
     self.assertEquals(res1.revision, 3)
     self.assertEquals(res2.revision, 2)
     self.assertTrue('33333' in data1)
     self.assertTrue('55555' in data2)
     self.assertEquals(data['test.xml'].revision, 3)
     self.assertEquals(data['test2.xml'].revision, 2)
     # delete resource
     data = proc.run(DELETE, '/get-test/vc/test.xml')
     data = proc.run(DELETE, '/get-test/vc/test2.xml')
 def test_getResourceIndex(self):
     """
     Tests resource index property.
     """
     proc = Processor(self.env)
     XML_DOC = XML_BASE_DOC % ("üöäß", "5")
     # create resource
     proc.run(POST, '/property-test/notvc/test.xml', StringIO(XML_DOC))
     # get index XML w/o trailing slash
     res = proc.run(GET, '/property-test/notvc/test.xml/.index')
     data = res.render_GET(proc)
     self.assertTrue("<label1>" in data)
     self.assertTrue("<value>üöäß</value>" in data)
     # get index XML w/ trailing slash
     res = proc.run(GET, '/property-test/notvc/test.xml/.index/')
     data = res.render_GET(proc)
     self.assertTrue("<label1>" in data)
     self.assertTrue("<value>üöäß</value>" in data)
     # get index XML on revision 1 w/o trailing slash
     res = proc.run(GET, '/property-test/notvc/test.xml/1/.index/')
     data = res.render_GET(proc)
     self.assertTrue("<label1>" in data)
     self.assertTrue("<value>üöäß</value>" in data)
     # get index XML on revision 1 w/ trailing slash
     res = proc.run(GET, '/property-test/notvc/test.xml/1/.index/')
     data = res.render_GET(proc)
     self.assertTrue("<label1>" in data)
     self.assertTrue("<value>üöäß</value>" in data)
     # remove resource
     proc.run(DELETE, '/property-test/notvc/test.xml')
 def test_getRevisionIndex(self):
     """
     Tests revision index property.
     """
     proc = Processor(self.env)
     # create resource
     XML_DOC2 = XML_BASE_DOC % ("üöäß", "%d")
     proc.run(POST, '/property-test/vc/test.xml/', StringIO(XML_DOC2 % 12))
     proc.run(PUT, '/property-test/vc/test.xml/', StringIO(XML_DOC2 % 234))
     proc.run(PUT, '/property-test/vc/test.xml/', StringIO(XML_DOC2 % 3456))
     # get index XML of latest revision w/o trailing slash
     res = proc.run(GET, '/property-test/vc/test.xml/.index')
     data = res.render_GET(proc)
     self.assertTrue("<label4>" in data)
     self.assertTrue("<value>3456</value>" in data)
     # get index XML of revision 3 w/o trailing slash
     res = proc.run(GET, '/property-test/vc/test.xml/3/.index')
     data = res.render_GET(proc)
     self.assertTrue("<label4>" in data)
     self.assertTrue("<value>3456</value>" in data)
     # get index XML of latest revision w/ trailing slash
     res = proc.run(GET, '/property-test/vc/test.xml/.index/')
     data = res.render_GET(proc)
     self.assertTrue("<label4>" in data)
     self.assertTrue("<value>3456</value>" in data)
     # get index XML of revision 3 w/ trailing slash
     res = proc.run(GET, '/property-test/vc/test.xml/3/.index/')
     data = res.render_GET(proc)
     self.assertTrue("<label4>" in data)
     self.assertTrue("<value>3456</value>" in data)
     # remove resource
     proc.run(DELETE, '/property-test/vc/test.xml')
Beispiel #13
0
 def test_deleteVersionControlledResource(self):
     """
     Successful deletion of version controlled resources.
     """
     proc = Processor(self.env)
     # create resource
     proc.run(POST, '/delete-test/vc/test.xml', StringIO(XML_DOC))
     proc.run(PUT, '/delete-test/vc/test.xml', StringIO(XML_VCDOC % 1))
     proc.run(PUT, '/delete-test/vc/test.xml', StringIO(XML_VCDOC % 2))
     # check latest resource - should be #20
     data = proc.run(GET, '/delete-test/vc/test.xml').render_GET(proc)
     self.assertEqual(data, XML_VCDOC % 2)
     # check oldest resource -> revision start with 1
     data = proc.run(GET, '/delete-test/vc/test.xml/1').render_GET(proc)
     self.assertEqual(data, XML_DOC)
     # delete resource
     data = proc.run(DELETE, '/delete-test/vc/test.xml')
     self.assertEqual(data, '')
     self.assertEqual(proc.code, http.NO_CONTENT)
     # fetch resource again
     try:
         proc.run(GET, '/delete-test/vc/test.xml').render_GET(proc)
         self.fail("Expected SeisHubError")
     except SeisHubError, e:
         self.assertEqual(e.code, http.NOT_FOUND)
 def test_validDateTimeIndexes(self):
     """
     Test indexing of XML documents with valid datetime fields.
     """
     proc = Processor(self.env)
     XML_DOC = XML_BASE_DOC % ("%s", "egal")
     # w/ T
     xml_doc = XML_DOC % "1970-12-20T12:12:21"
     proc.run(POST, '/property-test/notvc2/1', StringIO(xml_doc))
     data = proc.run(GET, '/property-test/notvc2/1/.index').render_GET(proc)
     self.assertTrue("<value>1970-12-20 12:12:21</value>" in data)
     proc.run(DELETE, '/property-test/notvc2/1')
     # w/o T
     xml_doc = XML_DOC % "1970-12-20 12:12:21"
     proc.run(POST, '/property-test/notvc2/1', StringIO(xml_doc))
     data = proc.run(GET, '/property-test/notvc2/1/.index').render_GET(proc)
     self.assertTrue("<value>1970-12-20 12:12:21</value>" in data)
     proc.run(DELETE, '/property-test/notvc2/1')
     # milliseconds, w/ T
     xml_doc = XML_DOC % "1970-12-20T12:12:21.123456"
     proc.run(POST, '/property-test/notvc2/1', StringIO(xml_doc))
     data = proc.run(GET, '/property-test/notvc2/1/.index').render_GET(proc)
     self.assertTrue("<value>1970-12-20 12:12:21.123456</value>" in data)
     proc.run(DELETE, '/property-test/notvc2/1')
     # milliseconds, w/o T
     xml_doc = XML_DOC % "1970-12-20 12:12:21.123456"
     proc.run(POST, '/property-test/notvc2/1', StringIO(xml_doc))
     data = proc.run(GET, '/property-test/notvc2/1/.index').render_GET(proc)
     self.assertTrue("<value>1970-12-20 12:12:21.123456</value>" in data)
     proc.run(DELETE, '/property-test/notvc2/1')
     # limited milliseconds, w/ T
     xml_doc = XML_DOC % "1970-12-20T12:12:21.123"
     proc.run(POST, '/property-test/notvc2/1', StringIO(xml_doc))
     data = proc.run(GET, '/property-test/notvc2/1/.index').render_GET(proc)
     self.assertTrue("<value>1970-12-20 12:12:21.123000</value>" in data)
     proc.run(DELETE, '/property-test/notvc2/1')
     # limited milliseconds, w/o T
     xml_doc = XML_DOC % "1970-12-20 12:12:21.123"
     proc.run(POST, '/property-test/notvc2/1', StringIO(xml_doc))
     data = proc.run(GET, '/property-test/notvc2/1/.index').render_GET(proc)
     self.assertTrue("<value>1970-12-20 12:12:21.123000</value>" in data)
     proc.run(DELETE, '/property-test/notvc2/1')
     # w/o time -> defaults to 00:00:00
     xml_doc = XML_DOC % "1970-12-20"
     proc.run(POST, '/property-test/notvc2/1', StringIO(xml_doc))
     data = proc.run(GET, '/property-test/notvc2/1/.index').render_GET(proc)
     self.assertTrue("<value>1970-12-20 00:00:00</value>" in data)
     proc.run(DELETE, '/property-test/notvc2/1')
     # w/o minutes and seconds -> defaults to :00:00
     xml_doc = XML_DOC % "19701220T12"
     proc.run(POST, '/property-test/notvc2/1', StringIO(xml_doc))
     data = proc.run(GET, '/property-test/notvc2/1/.index').render_GET(proc)
     self.assertTrue("<value>1970-12-20 12:00:00</value>" in data)
     proc.run(DELETE, '/property-test/notvc2/1')
     # w/o seconds -> defaults to :00
     xml_doc = XML_DOC % "19701220T12:13"
     proc.run(POST, '/property-test/notvc2/1', StringIO(xml_doc))
     data = proc.run(GET, '/property-test/notvc2/1/.index').render_GET(proc)
     self.assertTrue("<value>1970-12-20 12:13:00</value>" in data)
     proc.run(DELETE, '/property-test/notvc2/1')
Beispiel #15
0
 def test_getMultiFormatedResource(self):
     """
     Get resource in a certain format using multiple style sheets.
     """
     proc = Processor(self.env)
     # create resource
     proc.run(POST, '/transformation-test/rt/test.xml', StringIO(XML_DOC))
     # transform using a format chain
     proc.args = {'format': ['xml2html', 'html2txt']}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, TXT_DOC)
     # missing formats
     proc.args = {'format': ['XXX', 'YYY', 'ZZZ']}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, XML_DOC)
     # one valid format
     proc.args = {'format': ['XXX', 'xml2html', 'YYY']}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, HTML_DOC)
     # transform using a format chain but last style sheet is missing
     proc.args = {'format': ['xml2html', 'html2txt', 'XXX']}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, TXT_DOC)
     # transform using a format chain but one style sheet is missing
     proc.args = {'format': ['xml2html', 'XXX', 'html2txt']}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, TXT_DOC)
     # delete resource
     proc.run(DELETE, '/transformation-test/rt/test.xml')
Beispiel #16
0
 def test_getFormatedResource(self):
     """
     Get resource in a certain format using a single style sheet.
     """
     proc = Processor(self.env)
     # create resource
     proc.run(POST, '/transformation-test/rt/test.xml', StringIO(XML_DOC))
     # without format
     proc.args = {'format': []}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, XML_DOC)
     # transform to existing format HTML
     proc.args = {'format': ['xml2html']}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, HTML_DOC)
     # transform to existing format SVG
     proc.args = {'format': ['xml2svg']}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, SVG_DOC)
     # missing format
     proc.args = {'format': ['XXX']}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, XML_DOC)
     # delete resource
     proc.run(DELETE, '/transformation-test/rt/test.xml')
Beispiel #17
0
 def test_addChild(self):
     # add a few children with absolute path to resource tree
     self.env.tree.putChild('/test/muh/muh', ATestResource('maeh'))
     self.env.tree.putChild('/test/muh/kuh', ATestResource('muh'))
     # add children with relative path to resource tree
     self.env.tree.putChild('maeh', ATestResource('you'))
     self.env.tree.putChild('test2', ATestResource('again'))
     # check the resource tree
     proc = Processor(self.env)
     # root
     data = proc.run(GET, '/')
     self.assertTrue(isinstance(data, dict))
     self.assertTrue('maeh' in data)
     self.assertTrue('test' in data)
     self.assertTrue('test2' in data)
     # sub folder
     data = proc.run(GET, '/test')
     self.assertTrue(isinstance(data, dict))
     self.assertTrue('muh' in data)
     # sub sub folder
     data = proc.run(GET, '/test/muh')
     self.assertTrue(isinstance(data, dict))
     self.assertTrue('kuh' in data)
     self.assertTrue('muh' in data)
     # resources
     data = proc.run(GET, '/test/muh/kuh')
     self.assertEquals('Hello muh!', data)
     data = proc.run(GET, '/maeh')
     self.assertEquals('Hello you!', data)
     data = proc.run(GET, '/test2')
     self.assertEquals('Hello again!', data)
     data = proc.run(GET, '/test/muh/muh')
     self.assertEquals('Hello maeh!', data)
Beispiel #18
0
 def test_getRevision(self):
     proc = Processor(self.env)
     # create resource
     proc.run(POST, '/get-test/vc/test.xml', StringIO(XML_DOC))
     proc.run(PUT, '/get-test/vc/test.xml', StringIO(XML_DOC))
     proc.run(PUT, '/get-test/vc/test.xml', StringIO(XML_DOC))
     # without trailing slash
     res1 = proc.run(GET, '/get-test/vc/test.xml/1')
     data1 = res1.render_GET(proc)
     # with trailing slash
     res2 = proc.run(GET, '/get-test/vc/test.xml/1/')
     data2 = res2.render_GET(proc)
     # res must be RESTResource objects
     self.assertTrue(isinstance(res1, RESTResource))
     self.assertTrue(isinstance(res2, RESTResource))
     # both results should equal
     self.assertTrue(data1 == data2)
     # check content
     self.assertEquals(data1, XML_DOC)
     # GET revision 2
     res3 = proc.run(GET, '/get-test/vc/test.xml/2')
     data3 = res3.render_GET(proc)
     self.assertEquals(data3, XML_DOC)
     res4 = proc.run(GET, '/get-test/vc/test.xml/2/')
     data4 = res4.render_GET(proc)
     self.assertEquals(data4, XML_DOC)
     # delete resource
     proc.run(DELETE, '/get-test/vc/test.xml')
Beispiel #19
0
 def test_invalidMethods(self):
     proc = Processor(self.env)
     for method in ['MUH', 'XXX', 'GETPUT']:
         try:
             proc.run(method, '/')
             self.fail("Expected SeisHubError")
         except SeisHubError, e:
             self.assertEqual(e.code, http.NOT_ALLOWED)
Beispiel #20
0
 def test_getDisabledResourceType(self):
     proc = Processor(self.env)
     # without trailing slash
     try:
         proc.run(DELETE, '/get-test/notvc2')
         self.fail("Expected SeisHubError")
     except SeisHubError, e:
         self.assertEqual(e.code, http.NOT_FOUND)
 def test_executeResourceScript(self):
     """
     Files with extension '.rpy' should be interpreted as Resource scripts.
     """
     proc = Processor(self.env)
     for method in [POST, PUT, DELETE, MOVE, GET]:
         data = proc.run(method, '/scripts/test.rpy')
         self.assertEquals('<html>%s</html>' % method, data)
Beispiel #22
0
 def test_someRESTResourceTypes(self):
     proc = Processor(self.env)
     result = proc.run(GET, '/')
     self.assertTrue(isinstance(result.get('xml'), RESTFolder))
     result = proc.run(GET, '/xml')
     self.assertTrue(isinstance(result.get('seishub'), RESTPackageFolder))
     result = proc.run(GET, '/xml/seishub')
     self.assertTrue(
         isinstance(result.get('stylesheet'), RESTResourceTypeFolder))
Beispiel #23
0
 def test_dontReturnUnicodeFromMapper(self):
     """
     Unicodes returned from a mapper should be encoded into UTF-8 strings.
     """
     proc = Processor(self.env)
     data = proc.run(GET, '/testmapping4')
     self.assertFalse(isinstance(data, unicode))
     self.assertTrue(isinstance(data, basestring))
     self.assertEqual('MÜH', data)
Beispiel #24
0
 def test_deleteResourceInNotExistingResourceType(self):
     """
     Resource can't be deleted from not existing resource type.
     """
     proc = Processor(self.env)
     try:
         proc.run(DELETE, '/delete-test/notvc2/test.xml')
         self.fail("Expected SeisHubError")
     except SeisHubError, e:
         self.assertEqual(e.code, http.NOT_FOUND)
Beispiel #25
0
 def test_notImplementedMethods(self):
     """
     Not implemented methods should raise an error.
     """
     proc = Processor(self.env)
     try:
         proc.run('MUH', '/testmapping4')
         self.fail("Expected SeisHubError")
     except SeisHubError, e:
         self.assertEqual(e.code, http.NOT_ALLOWED)
 def test_invalidResourceIDs(self):
     """
     Resource names have to be alphanumeric, start with a character
     """
     proc = Processor(self.env)
     # root
     try:
         proc.run(POST, '/put-test/notvc/üö$%&', StringIO(XML_DOC))
         self.fail("Expected SeisHubError")
     except SeisHubError, e:
         self.assertEqual(e.code, http.BAD_REQUEST)
Beispiel #27
0
 def test_orderOfAddingResourcesMatters(self):
     """
     This test in this specific order failed in a previous revision.
     """
     proc = Processor(self.env)
     proc.run(POST, '/rest-test/vc/test.xml', StringIO(XML_DOC))
     proc.run(PUT, '/rest-test/vc/test.xml', StringIO(XML_DOC))
     proc.run(PUT, '/rest-test/vc/test.xml', StringIO(XML_DOC))
     proc.run(POST, '/rest-test/notvc/test.xml', StringIO(XML_DOC))
     proc.run(DELETE, '/rest-test/vc/test.xml')
     proc.run(DELETE, '/rest-test/notvc/test.xml')
Beispiel #28
0
 def test_deleteResourceInNotExistingPackage(self):
     """
     Resource can't be deleted from not existing package.
     """
     proc = Processor(self.env)
     # with trailing slash
     try:
         proc.run(DELETE, '/delete-test2/notvc/test.xml')
         self.fail("Expected SeisHubError")
     except SeisHubError, e:
         self.assertEqual(e.code, http.NOT_FOUND)
Beispiel #29
0
 def test_deletePackage(self):
     """
     SeisHub processor does not allow deletion of packages.
     """
     proc = Processor(self.env)
     # without trailing slash
     try:
         proc.run(DELETE, '/delete-test')
         self.fail("Expected SeisHubError")
     except SeisHubError, e:
         self.assertEqual(e.code, http.NOT_ALLOWED)
Beispiel #30
0
 def test_deleteNotExistingPackage(self):
     """
     A not existing resource package can't be deleted.
     """
     proc = Processor(self.env)
     # without trailing slash
     try:
         proc.run(DELETE, '/xxx')
         self.fail("Expected SeisHubError")
     except SeisHubError, e:
         self.assertEqual(e.code, http.NOT_FOUND)