1. Testing results for existing identifiers. 2. Testing version parameter options
This commit is contained in:
parent
3ce8bcf316
commit
e7e3542216
1 changed files with 37 additions and 2 deletions
|
|
@ -2,6 +2,7 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
import falcon
|
||||
from falcon import testing
|
||||
|
||||
api_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..','api'))
|
||||
|
|
@ -15,9 +16,43 @@ class APITest(testing.TestCase):
|
|||
|
||||
self.app = create_ident_getter()
|
||||
|
||||
class TestMyApp(APITest):
|
||||
def test_identifier_not_found(self):
|
||||
result = self.simulate_get('/ident/tree/SOME_NONEXISTENT_IDENTIFIER', query_string="version=latest")
|
||||
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertEqual(result.json, {'definitions': [], 'references':[]})
|
||||
self.assertEqual(result.json, {'definitions': [], 'references':[]})
|
||||
|
||||
def test_missing_version(self):
|
||||
# A get request without a version query string
|
||||
result = self.simulate_get('/ident/tree/of_i2c_get_board_info')
|
||||
|
||||
self.assertEqual(result.status_code, 400)
|
||||
|
||||
required_response = falcon.HTTPMissingParam('version')
|
||||
self.assertEqual(result.json["title"], required_response.title)
|
||||
self.assertEqual(result.json["description"], required_response.description)
|
||||
|
||||
def test_existing_identifier(self):
|
||||
result_for_specific_version = self.simulate_get('/ident/tree/of_i2c_get_board_info', query_string="version=v5.4")
|
||||
result_for_latest_version = self.simulate_get('/ident/tree/of_i2c_get_board_info', query_string="version=latest")
|
||||
|
||||
expected_json = {
|
||||
'definitions':
|
||||
[
|
||||
{'path': 'drivers/i2c/i2c-core-of.c', 'line': 22, 'type': 'function'},
|
||||
{'path': 'drivers/i2c/i2c-core-of.c', 'line': 62, 'type': 'variable'},
|
||||
{'path': 'include/linux/i2c.h', 'line': 968, 'type': 'function'},
|
||||
{'path': 'include/linux/i2c.h', 'line': 941, 'type': 'prototype'}
|
||||
],
|
||||
'references':
|
||||
[
|
||||
{'path': 'drivers/i2c/i2c-core-of.c', 'line': '22,62,73', 'type': None},
|
||||
{'path': 'include/linux/i2c.h', 'line': '941,968', 'type': None}
|
||||
]
|
||||
}
|
||||
|
||||
self.assertEqual(result_for_specific_version.status_code, 200)
|
||||
self.assertEqual(result_for_latest_version.status_code, 200)
|
||||
|
||||
self.assertEqual(result_for_specific_version.json, expected_json)
|
||||
self.assertEqual(result_for_latest_version.json, expected_json)
|
||||
Loading…
Reference in a new issue