Пример #1
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"))
Пример #2
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"))
Пример #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"))
Пример #4
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"))
Пример #5
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)
Пример #6
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)