mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
tests for informational endpoints
This commit is contained in:
parent
80f3bb3809
commit
990d863dc7
@ -10,7 +10,16 @@ from bigchaindb import version
|
|||||||
|
|
||||||
class RootIndex(Resource):
|
class RootIndex(Resource):
|
||||||
def get(self):
|
def get(self):
|
||||||
|
docs_url = [
|
||||||
|
'https://docs.bigchaindb.com/projects/server/en/',
|
||||||
|
version.__short_version__ + '/'
|
||||||
|
]
|
||||||
|
api_v1_url = base_url() + 'api/v1/'
|
||||||
return flask.jsonify({
|
return flask.jsonify({
|
||||||
|
'_links': {
|
||||||
|
'docs': ''.join(docs_url),
|
||||||
|
'api_v1': api_v1_url,
|
||||||
|
},
|
||||||
'software': 'BigchainDB',
|
'software': 'BigchainDB',
|
||||||
'version': version.__version__,
|
'version': version.__version__,
|
||||||
'public_key': bigchaindb.config['keypair']['public'],
|
'public_key': bigchaindb.config['keypair']['public'],
|
||||||
@ -21,16 +30,16 @@ class RootIndex(Resource):
|
|||||||
class ApiV1Index(Resource):
|
class ApiV1Index(Resource):
|
||||||
def get(self):
|
def get(self):
|
||||||
api_root = base_url() + 'api/v1/'
|
api_root = base_url() + 'api/v1/'
|
||||||
docs_url = ['https://docs.bigchaindb.com/projects/server/en/',
|
docs_url = [
|
||||||
version.__short_version__,
|
'https://docs.bigchaindb.com/projects/server/en/',
|
||||||
'/drivers-clients/http-client-server-api.html',
|
version.__short_version__,
|
||||||
]
|
'/drivers-clients/http-client-server-api.html',
|
||||||
|
]
|
||||||
return {
|
return {
|
||||||
"_links": {
|
"_links": {
|
||||||
"docs": {"href": ''.join(docs_url)},
|
"docs": ''.join(docs_url),
|
||||||
"self": {"href": api_root},
|
"self": api_root,
|
||||||
"statuses": {"href": api_root + "statuses/"},
|
"statuses": api_root + "statuses/",
|
||||||
"transactions": {"href": api_root + "transactions/"},
|
"transactions": api_root + "transactions/",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,35 @@
|
|||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
|
|
||||||
def test_api_root_url_shows_basic_info(client):
|
@mock.patch('bigchaindb.version.__short_version__', 'tst')
|
||||||
from bigchaindb import version
|
@mock.patch('bigchaindb.version.__version__', 'tsttst')
|
||||||
|
@mock.patch('bigchaindb.config', {'keyring': ['abc'], 'keypair': {'public': 'def'}})
|
||||||
|
def test_api_root_endpoint(client):
|
||||||
res = client.get('/')
|
res = client.get('/')
|
||||||
assert res.json['software'] == 'BigchainDB'
|
assert res.json == {
|
||||||
assert res.json['version'] == version.__version__
|
'_links': {
|
||||||
|
'docs': 'https://docs.bigchaindb.com/projects/server/en/tst/',
|
||||||
|
'api_v1': 'http://localhost/api/v1/',
|
||||||
|
},
|
||||||
|
'version': 'tsttst',
|
||||||
|
'keyring': ['abc'],
|
||||||
|
'public_key': 'def',
|
||||||
|
'software': 'BigchainDB',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@mock.patch('bigchaindb.version.__short_version__', 'tst')
|
||||||
def test_api_v1_endpoint(client):
|
def test_api_v1_endpoint(client):
|
||||||
with mock.patch('bigchaindb.version.__short_version__', 'tst'):
|
res = client.get('/api/v1')
|
||||||
res = client.get('/api/v1')
|
|
||||||
docs_url = ['https://docs.bigchaindb.com/projects/server/en/',
|
docs_url = ['https://docs.bigchaindb.com/projects/server/en/',
|
||||||
'tst',
|
'tst',
|
||||||
'/drivers-clients/http-client-server-api.html',
|
'/drivers-clients/http-client-server-api.html',
|
||||||
]
|
]
|
||||||
assert res.json == {
|
assert res.json == {
|
||||||
'_links': {
|
'_links': {
|
||||||
'docs': {'href': ''.join(docs_url)},
|
'docs': ''.join(docs_url),
|
||||||
'self': {'href': 'http://localhost/api/v1/'},
|
'self': 'http://localhost/api/v1/',
|
||||||
'statuses': {'href': 'http://localhost/api/v1/statuses/'},
|
'statuses': 'http://localhost/api/v1/statuses/',
|
||||||
'transactions': {'href': 'http://localhost/api/v1/transactions/'}
|
'transactions': 'http://localhost/api/v1/transactions/',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user