bigchaindb/tests/web/test_info.py
muawiakh 82cd3a61ed Add metadata endpoint to info view
- Metadata search was recently added and works seamlessly
- The endpoint was not reflected in the info view i.e.
  when someone queries at root / or api/v1 endpoints.
- Handle unit tests for the change as well.
2017-11-22 18:31:35 +01:00

49 lines
1.8 KiB
Python

from unittest import mock
@mock.patch('bigchaindb.version.__short_version__', 'tst')
@mock.patch('bigchaindb.version.__version__', 'tsttst')
@mock.patch('bigchaindb.config', {'keyring': ['abc'], 'keypair': {'public': 'def'}})
def test_api_root_endpoint(client, wsserver_base_url):
res = client.get('/')
docs_url = ['https://docs.bigchaindb.com/projects/server/en/vtsttst',
'/http-client-server-api.html']
assert res.json == {
'api': {
'v1': {
'docs': ''.join(docs_url),
'transactions': '/api/v1/transactions/',
'statuses': '/api/v1/statuses/',
'assets': '/api/v1/assets/',
'outputs': '/api/v1/outputs/',
'streams': '{}/api/v1/streams/valid_transactions'.format(
wsserver_base_url),
"metadata": "/api/v1/metadata/"
}
},
'docs': 'https://docs.bigchaindb.com/projects/server/en/vtsttst/',
'version': 'tsttst',
'keyring': ['abc'],
'public_key': 'def',
'software': 'BigchainDB',
}
@mock.patch('bigchaindb.version.__short_version__', 'tst')
@mock.patch('bigchaindb.version.__version__', 'tsttst')
def test_api_v1_endpoint(client, wsserver_base_url):
docs_url = ['https://docs.bigchaindb.com/projects/server/en/vtsttst',
'/http-client-server-api.html']
api_v1_info = {
'docs': ''.join(docs_url),
'transactions': '/transactions/',
'statuses': '/statuses/',
'assets': '/assets/',
'outputs': '/outputs/',
'streams': '{}/api/v1/streams/valid_transactions'.format(
wsserver_base_url),
"metadata": "/metadata/"
}
res = client.get('/api/v1')
assert res.json == api_v1_info