-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding tests for dependent robinhood endpoints
- Loading branch information
Showing
6 changed files
with
109 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,29 @@ | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"min_tick_size", | ||
"min_tick_size": {"type":"null"}, | ||
"type": {"type":"string", "enum":["stock"]}, | ||
"margin_initial_ratio": {"type":"number"}, | ||
"splits": {"type":"string", "format":"uri"}, | ||
"margin_initial_ratio": {"type":"string"}, | ||
"url": {"type":"string", "format":"uri"}, | ||
"quote": {"type":"string", "format":"uri"}, | ||
"symbol": {"type":"string"}, | ||
"bloomberg_unique": {"type":"string", "pattern":"EQ\d{16}"}, | ||
"bloomberg_unique": {"type":"string", "pattern":"EQ\\d{16}"}, | ||
"list_date": {"type":"string", "format":"date-time"}, | ||
"name": {"type":"string"}, | ||
"fundamentals": {"type":"string", "format":"uri"}, | ||
"state": {"type":"string", "enum":["active"]}, | ||
"country": {"type":"string"}, | ||
"day_trade_ratio": {"type":"number"}, | ||
"day_trade_ratio": {"type":"string"}, | ||
"tradeable": {"type":"boolean"}, | ||
"maintenance_ratio": {"type":"number"}, | ||
"maintenance_ratio": {"type":"string"}, | ||
"id": {"type":"string"}, | ||
"market": {"type":"string", "format":"uri"}, | ||
"simple_name": {"type":"string"} | ||
}, | ||
"required": [ | ||
"min_tick_size", "type", "margin_initial_ratio", "url", "quote", "symbol", | ||
"bloomberg_unique", "list_date", "name", "fundamentals", "state", "country", | ||
"bloomberg_unique", "list_date", "name", "fundamentals", "country", | ||
"day_trade_ratio", "tradeable", "maintenance_ratio", "id", "market","simple_name"], | ||
"additionalProperties": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
"""test_stocks_news.py: validate behavior for datareader.stocks.prices""" | ||
from datetime import datetime | ||
from os import path | ||
|
||
import pytest | ||
import requests | ||
import helpers | ||
|
||
import prosper.datareader.stocks.prices as prices | ||
import prosper.datareader.exceptions as exceptions | ||
|
||
class TestExpectedSchemas: | ||
good_ticker = helpers.CONFIG.get('STOCKS', 'good_ticker') | ||
markets_url = helpers.CONFIG.get('STOCKS', 'markets_url') | ||
ticker_list = helpers.CONFIG.get('STOCKS', 'ticker_list').split(',') | ||
instruments_url = helpers.CONFIG.get('STOCKS', 'instruments_url') | ||
instruments_ticker = helpers.CONFIG.get('STOCKS', 'instruments_ticker') | ||
today = datetime.utcnow().strftime('%Y-%m-%d') | ||
|
||
def test_validate_quotes_endpoint(self): | ||
"""make sure /quotes endpoint works as expected""" | ||
for ticker in self.ticker_list: | ||
quote = prices.fetch_price_quotes_rh(ticker) | ||
|
||
helpers.validate_schema(quote, 'stocks/rh_quotes.schema') | ||
|
||
def test_validate_fundamentals_endpoint(self): | ||
"""make sure /fundamentals endpoint works as expected""" | ||
for ticker in self.ticker_list: | ||
fundamental = prices.fetch_fundamentals_rh(ticker) | ||
|
||
helpers.validate_schema(fundamental, 'stocks/rh_fundamentals.schema') | ||
|
||
def test_validate_instruments_rh(self): | ||
"""make sure /instruments endpoint works as expected""" | ||
instrument = prices.fetch_instruments_rh(self.instruments_url) | ||
|
||
helpers.validate_schema(instrument, 'stocks/rh_instruments.schema') | ||
|
||
assert instrument['symbol'] == self.instruments_ticker | ||
|
||
def test_validate_market_info(self): | ||
"""make sure /markets endpoint works as expected""" | ||
market_req = requests.get(self.markets_url) | ||
market_req.raise_for_status() | ||
|
||
market = market_req.json() | ||
|
||
helpers.validate_schema(market, 'stocks/rh_markets.schema') | ||
|
||
def test_validate_market_hours(self): | ||
"""make sure /markets/hours works as expected""" | ||
url = '{markets_url}hours/{today}'.format( | ||
markets_url=self.markets_url, | ||
today=self.today) | ||
|
||
hours_req = requests.get(url) | ||
hours_req.raise_for_status() | ||
|
||
hours = hours_req.json() | ||
|
||
helpers.validate_schema(hours, 'stocks/rh_markets_hours.schema') |