Ejemplo n.º 1
0
 def test_handler_bad_location_outside_project_root(self):
     "file at location may exist but is outside of project dir"
     self.valid_request['location'] = 'file:///dev/null'
     adapt.handler(self.valid_request, self.out)
     self.assertEqual(len(self.out.errors), 1)
     self.assertTrue(
         self.out.errors[0]['message'].startswith("refusing to download"))
Ejemplo n.º 2
0
 def test_handler_bad_render2(self):
     "article xml fails to convert truncated xml to article-json"
     self.valid_request['location'] = 'file://' + join(
         self.ingest_dir, 'bad', 'truncated.xml')
     adapt.handler(self.valid_request, self.out)
     self.assertEqual(len(self.out.errors), 1)
     self.assertTrue(
         self.out.errors[0]['message'].startswith("failed to render"))
Ejemplo n.º 3
0
 def test_handler_bad_location(self):
     "location with missing file generates an error"
     self.valid_request['location'] = 'file://' + join(
         conf.PROJECT_DIR, 'does-not-exist.xml')
     adapt.handler(self.valid_request, self.out)
     self.assertEqual(len(self.out.errors), 1)
     self.assertTrue(
         self.out.errors[0]['message'].startswith("failed to download"))
Ejemplo n.º 4
0
 def test_handler_good_json_but_invalid(self):
     "good json but invalid request generates an error"
     adapt.handler('{"I-hope-you-have-a-very": "pants-party"}', self.out)
     self.assertEqual(len(self.out.errors), 1)
Ejemplo n.º 5
0
 def test_handler_bad_bad_data(self):
     "something about the data causes an unhandled exception that generate an error"
     adapt.handler(lambda x: x, self.out)
     self.assertEqual(len(self.out.errors), 1)
     self.assertTrue(
         self.out.errors[0]["message"].startswith("unhandled error"))
Ejemplo n.º 6
0
 def test_handler_bad_render2(self):
     "article xml fails to convert truncated xml to article-json"
     self.valid_request['location'] = 'file://' + join(self.ingest_dir, 'bad', 'truncated.xml')
     adapt.handler(self.valid_request, self.out)
     self.assertEqual(len(self.out.errors), 1)
     self.assertTrue(self.out.errors[0]['message'].startswith("failed to render"))
Ejemplo n.º 7
0
 def test_handler_bad_json(self):
     "bad json request generates an error"
     adapt.handler("pants-party", self.out)
     self.assertEqual(len(self.out.errors), 1)
Ejemplo n.º 8
0
 def test_handler_bad_location_outside_project_root(self):
     "file at location may exist but is outside of project dir"
     self.valid_request['location'] = 'file:///dev/null'
     adapt.handler(self.valid_request, self.out)
     self.assertEqual(len(self.out.errors), 1)
     self.assertTrue(self.out.errors[0]['message'].startswith("refusing to download"))
Ejemplo n.º 9
0
 def test_handler_bad_location(self):
     "location with missing file generates an error"
     self.valid_request['location'] = 'file://' + join(conf.PROJECT_DIR, 'does-not-exist.xml')
     adapt.handler(self.valid_request, self.out)
     self.assertEqual(len(self.out.errors), 1)
     self.assertTrue(self.out.errors[0]['message'].startswith("failed to download"))
Ejemplo n.º 10
0
 def test_handler_bad_bad_data(self):
     "something about the data causes an unhandled exception that generate an error"
     adapt.handler(lambda x: x, self.out)
     self.assertEqual(len(self.out.errors), 1)
     self.assertTrue(self.out.errors[0]["message"].startswith("unhandled error"))
Ejemplo n.º 11
0
 def test_handler_good_json_but_invalid(self):
     "good json but invalid request generates an error"
     adapt.handler('{"I-hope-you-have-a-very": "pants-party"}', self.out)
     self.assertEqual(len(self.out.errors), 1)
Ejemplo n.º 12
0
 def test_handler_bad_json(self):
     "bad json request generates an error"
     adapt.handler("pants-party", self.out)
     self.assertEqual(len(self.out.errors), 1)