Change data endpoint to block range

This commit is contained in:
nolash
2021-05-18 18:16:02 +02:00
parent f035bd3e9f
commit dd9305a0f2
6 changed files with 33 additions and 19 deletions

View File

@@ -1,6 +1,9 @@
# standard imports
import json
# external imports
import pytest
# local imports
from cic_cache.runnable.daemons.query import process_transactions_all_data
@@ -11,10 +14,18 @@ def test_api_all_data(
):
env = {
'PATH_INFO': '/tx/0/100',
'PATH_INFO': '/txa/410000/420000',
'HTTP_X_CIC_CACHE_MODE': 'all',
}
j = process_transactions_all_data(init_database, env)
o = json.loads(j[1])
assert len(o['data']) == 2
env = {
'PATH_INFO': '/txa/420000/410000',
'HTTP_X_CIC_CACHE_MODE': 'all',
}
with pytest.raises(ValueError):
j = process_transactions_all_data(init_database, env)

View File

@@ -47,10 +47,10 @@ def test_cache_data(
session = init_database
c = DataCache(session)
b = c.load_transactions_with_data(0, 100)
b = c.load_transactions_with_data(410000, 420000)
assert len(b[2]) == 2
assert b[2][0]['tx_hash'] == txs[0]
assert b[2][0]['tx_type'] == 'unknown'
assert b[2][1]['tx_type'] == 'test.taag'
assert b[2][0]['tx_hash'] == txs[1]
assert b[2][1]['tx_type'] == 'unknown'
assert b[2][0]['tx_type'] == 'test.taag'