From 2106256f89794bc7334ecf1c62b982b5c5c83dcd Mon Sep 17 00:00:00 2001 From: Stefan Haun Date: Tue, 1 Dec 2020 21:03:11 +0100 Subject: [PATCH] Add simple validation test case --- test.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test.py b/test.py index 84a6315..ee268d3 100644 --- a/test.py +++ b/test.py @@ -38,5 +38,25 @@ class TestBaseAPI(tornado.testing.AsyncHTTPTestCase): 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__": unittest.main()