Add simple validation test case

This commit is contained in:
Stefan Haun 2020-12-01 21:03:11 +01:00
parent 74d6e2ea5c
commit 9dc82b769b

20
test.py
View file

@ -38,5 +38,25 @@ class TestBaseAPI(tornado.testing.AsyncHTTPTestCase):
self.assertEqual(response.body.decode(), oas3f.read(), "OAS3 content differs from spec file!") self.assertEqual(response.body.decode(), oas3f.read(), "OAS3 content differs from spec file!")
class TestValidation(tornado.testing.AsyncHTTPTestCase):
"""Validation test cases"""
def get_app(self):
return make_app()
def test_null_validation(self):
entity = {}
response = self.fetch('/v0/validate',
method='POST',
body=json.dumps(entity))
self.assertEqual(200, response.code, "Validation must always return 200")
validation_result = json.loads(response.body.decode())
self.assertIn('valid', validation_result, "Key 'valid' expected in validation result")
self.assertTrue(validation_result['valid'], "Validation result is expected to be valid==true")
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()