mirror of
https://github.com/Reckless-Satoshi/robosats.git
synced 2024-09-11 11:55:26 +03:00
Add historical api tests
This commit is contained in:
parent
dd7534d64a
commit
6abb84ff5d
@ -718,11 +718,11 @@ class HistoricalViewSchema:
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"volume": {
|
"volume": {
|
||||||
"type": "integer",
|
"type": "number",
|
||||||
"description": "Total Volume traded on that particular date",
|
"description": "Total Volume traded on that particular date",
|
||||||
},
|
},
|
||||||
"num_contracts": {
|
"num_contracts": {
|
||||||
"type": "number",
|
"type": "integer",
|
||||||
"description": "Number of successful trades on that particular date",
|
"description": "Number of successful trades on that particular date",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -734,10 +734,8 @@ class HistoricalViewSchema:
|
|||||||
"Truncated example",
|
"Truncated example",
|
||||||
value={
|
value={
|
||||||
"<date>": {
|
"<date>": {
|
||||||
"code": "USD",
|
"volume": 0.69,
|
||||||
"price": "42069.69",
|
"num_contracts": 69,
|
||||||
"min_amount": "4.2",
|
|
||||||
"max_amount": "420.69",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
status_codes=[200],
|
status_codes=[200],
|
||||||
|
@ -122,20 +122,18 @@ paths:
|
|||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
volume:
|
volume:
|
||||||
type: integer
|
type: number
|
||||||
description: Total Volume traded on that particular date
|
description: Total Volume traded on that particular date
|
||||||
num_contracts:
|
num_contracts:
|
||||||
type: number
|
type: integer
|
||||||
description: Number of successful trades on that particular
|
description: Number of successful trades on that particular
|
||||||
date
|
date
|
||||||
examples:
|
examples:
|
||||||
TruncatedExample:
|
TruncatedExample:
|
||||||
value:
|
value:
|
||||||
- <date>:
|
- <date>:
|
||||||
code: USD
|
volume: 0.69
|
||||||
price: '42069.69'
|
num_contracts: 69
|
||||||
min_amount: '4.2'
|
|
||||||
max_amount: '420.69'
|
|
||||||
summary: Truncated example
|
summary: Truncated example
|
||||||
description: ''
|
description: ''
|
||||||
/api/info/:
|
/api/info/:
|
||||||
|
@ -11,7 +11,7 @@ from api.management.commands.follow_invoices import Command as FollowInvoices
|
|||||||
from api.models import Currency, Order
|
from api.models import Currency, Order
|
||||||
from api.tasks import cache_market, follow_send_payment
|
from api.tasks import cache_market, follow_send_payment
|
||||||
from control.models import BalanceLog
|
from control.models import BalanceLog
|
||||||
from control.tasks import compute_node_balance
|
from control.tasks import compute_node_balance, do_accounting
|
||||||
from tests.node_utils import (
|
from tests.node_utils import (
|
||||||
add_invoice,
|
add_invoice,
|
||||||
create_address,
|
create_address,
|
||||||
@ -927,6 +927,31 @@ class TradeTest(BaseAPITestCase):
|
|||||||
self.assertIsInstance(data[0]["premium"], str)
|
self.assertIsInstance(data[0]["premium"], str)
|
||||||
self.assertIsInstance(data[0]["fee"], str)
|
self.assertIsInstance(data[0]["fee"], str)
|
||||||
|
|
||||||
|
def test_daily_historical(self):
|
||||||
|
"""
|
||||||
|
Tests the daily history serving endpoint after creating a contract
|
||||||
|
"""
|
||||||
|
path = reverse("historical")
|
||||||
|
self.trade_to_confirm_fiat_received_LN(self.maker_form_buy_with_range)
|
||||||
|
|
||||||
|
# Invoke the background thread that will call the celery-worker to follow_send_payment()
|
||||||
|
self.send_payments()
|
||||||
|
|
||||||
|
# Do daily accounting to create the daily summary
|
||||||
|
do_accounting()
|
||||||
|
|
||||||
|
response = self.client.get(path)
|
||||||
|
data = response.json()
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
# self.assertResponse(response) # Expects an array, but response is an object
|
||||||
|
first_date = list(data.keys())[0]
|
||||||
|
self.assertIsInstance(datetime.fromisoformat(first_date), datetime)
|
||||||
|
self.assertIsInstance(data[first_date]["volume"], float)
|
||||||
|
self.assertIsInstance(data[first_date]["num_contracts"], int)
|
||||||
|
|
||||||
|
print(data)
|
||||||
|
|
||||||
def test_book(self):
|
def test_book(self):
|
||||||
"""
|
"""
|
||||||
Tests public book view
|
Tests public book view
|
||||||
|
Loading…
Reference in New Issue
Block a user