revert linebreaks, no need to limit to 80 char lines
This commit is contained in:
parent
7609c08cb4
commit
afee6c62a6
2 changed files with 23 additions and 46 deletions
9
app.py
9
app.py
|
@ -35,8 +35,7 @@ class HealthHandler(tornado.web.RequestHandler, metaclass=ABCMeta):
|
|||
# if not available, try git
|
||||
if v is None:
|
||||
try:
|
||||
v = subprocess.check_output(["git", "describe", "--always",
|
||||
"--dirty"],
|
||||
v = subprocess.check_output(["git", "describe", "--always", "--dirty"],
|
||||
cwd=os.path.dirname(__file__)).strip().decode()
|
||||
except subprocess.CalledProcessError as e:
|
||||
print("Checking git version lead to non-null return code ",
|
||||
|
@ -52,8 +51,7 @@ class HealthHandler(tornado.web.RequestHandler, metaclass=ABCMeta):
|
|||
health['git-version'] = self.git_version
|
||||
|
||||
health['timestamp'] = isodate.datetime_isoformat(datetime.now())
|
||||
health['uptime'] = isodate.duration_isoformat(datetime.now()
|
||||
- startup_timestamp)
|
||||
health['uptime'] = isodate.duration_isoformat(datetime.now() - startup_timestamp)
|
||||
|
||||
self.set_header("Content-Type", "application/json")
|
||||
self.write(json.dumps(health, indent=4))
|
||||
|
@ -64,8 +62,7 @@ class Oas3Handler(tornado.web.RequestHandler, metaclass=ABCMeta):
|
|||
def get(self):
|
||||
self.set_header("Content-Type", "text/plain")
|
||||
# This is the proposed content type,
|
||||
# but browsers like Firefox try to download instead of
|
||||
# display the content
|
||||
# but browsers like Firefox try to download instead of display the content
|
||||
# self.set_header("Content-Type", "text/vnd.yml")
|
||||
with open('OAS3.yml', 'r') as f:
|
||||
oas3 = f.read()
|
||||
|
|
60
test.py
60
test.py
|
@ -22,16 +22,11 @@ class TestBaseAPI(tornado.testing.AsyncHTTPTestCase):
|
|||
|
||||
health = json.loads(response.body.decode())
|
||||
|
||||
self.assertIn('api-version', health,
|
||||
msg="api-version is not provided by health endpoint")
|
||||
self.assertEqual("v0", health['api-version'],
|
||||
msg="API version should be v0")
|
||||
self.assertIn('git-version', health,
|
||||
msg="git-version is not provided by health endpoint")
|
||||
self.assertIn('timestamp', health,
|
||||
msg="timestamp is not provided by health endpoint")
|
||||
self.assertIn('uptime', health,
|
||||
msg="uptime is not provided by health endpoint")
|
||||
self.assertIn('api-version', health, msg="api-version is not provided by health endpoint")
|
||||
self.assertEqual("v0", health['api-version'], msg="API version should be v0")
|
||||
self.assertIn('git-version', health, msg="git-version is not provided by health endpoint")
|
||||
self.assertIn('timestamp', health, msg="timestamp is not provided by health endpoint")
|
||||
self.assertIn('uptime', health, msg="uptime is not provided by health endpoint")
|
||||
|
||||
def test_oas3(self):
|
||||
response = self.fetch('/v0/oas3',
|
||||
|
@ -40,8 +35,7 @@ class TestBaseAPI(tornado.testing.AsyncHTTPTestCase):
|
|||
|
||||
# check contents against local OAS3.yml
|
||||
with open('OAS3.yml') as oas3f:
|
||||
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):
|
||||
|
@ -56,15 +50,12 @@ class TestValidation(tornado.testing.AsyncHTTPTestCase):
|
|||
method='POST',
|
||||
body=json.dumps(entity))
|
||||
|
||||
self.assertEqual(200, response.code,
|
||||
"Validation must always return 200")
|
||||
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.assertFalse(validation_result['valid'],
|
||||
"Validation result is expected to be valid==false")
|
||||
self.assertIn('valid', validation_result, "Key 'valid' expected in validation result")
|
||||
self.assertFalse(validation_result['valid'], "Validation result is expected to be valid==false")
|
||||
|
||||
def test_valid_entity(self):
|
||||
with open('test_cases/valid/valid.json', 'r') af f:
|
||||
|
@ -74,15 +65,12 @@ class TestValidation(tornado.testing.AsyncHTTPTestCase):
|
|||
method='POST',
|
||||
body=json.dumps(entity_file))
|
||||
|
||||
self.assertEqual(200, response.code,
|
||||
"Validation must always return 200")
|
||||
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")
|
||||
self.assertIn('valid', validation_result, "Key 'valid' expected in validation result")
|
||||
self.assertTrue(validation_result['valid'], "Validation result is expected to be valid==true")
|
||||
|
||||
def test_invalid_iban(self):
|
||||
with open('test_cases/invalid/invalid_iban.json', 'r') af f:
|
||||
|
@ -92,15 +80,12 @@ class TestValidation(tornado.testing.AsyncHTTPTestCase):
|
|||
method='POST',
|
||||
body=json.dumps(entity_file))
|
||||
|
||||
self.assertEqual(200, response.code,
|
||||
"Validation must always return 200")
|
||||
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.assertFalse(validation_result['valid'],
|
||||
"Validation result is expected to be valid==false")
|
||||
self.assertIn('valid', validation_result, "Key 'valid' expected in validation result")
|
||||
self.assertFalse(validation_result['valid'], "Validation result is expected to be valid==false")
|
||||
|
||||
def test_missing_id(self):
|
||||
with open('test_cases/invalid/missing_id.json', 'r') af f:
|
||||
|
@ -110,15 +95,12 @@ class TestValidation(tornado.testing.AsyncHTTPTestCase):
|
|||
method='POST',
|
||||
body=json.dumps(entity_file))
|
||||
|
||||
self.assertEqual(200, response.code,
|
||||
"Validation must always return 200")
|
||||
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.assertFalse(validation_result['valid'],
|
||||
"Validation result is expected to be valid==false")
|
||||
self.assertIn('valid', validation_result, "Key 'valid' expected in validation result")
|
||||
self.assertFalse(validation_result['valid'], "Validation result is expected to be valid==false")
|
||||
self.assertIn('id', validation_result['errors'])
|
||||
|
||||
def test_invalid_id(self):
|
||||
|
@ -134,10 +116,8 @@ class TestValidation(tornado.testing.AsyncHTTPTestCase):
|
|||
|
||||
validation_result = json.loads(response.body.decode())
|
||||
|
||||
self.assertIn('valid', validation_result,
|
||||
"Key 'valid' expected in validation result")
|
||||
self.assertFalse(validation_result['valid'],
|
||||
"Validation result is expected to be valid==false")
|
||||
self.assertIn('valid', validation_result, "Key 'valid' expected in validation result")
|
||||
self.assertFalse(validation_result['valid'], "Validation result is expected to be valid==false")
|
||||
self.assertIn('id', validation_result['errors'])
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue