Skip to content

Commit

Permalink
refactor test_api
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricporter committed Apr 8, 2017
1 parent 00063b9 commit 9d88cad
Showing 1 changed file with 64 additions and 40 deletions.
104 changes: 64 additions & 40 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,38 @@ def test_api():
print(u"Testing API......")
from rqalpha import run

from tests.api.test_api_base import test_get_order_code_new, test_get_open_order_code_new, \
test_cancel_order_code_new, \
test_update_universe_code_new, test_subscribe_code_new, test_unsubscribe_code_new, \
test_get_yield_curve_code_new, \
test_history_bars_code_new, test_all_instruments_code_new, test_instruments_code_new, test_sector_code_new, \
test_concept_code_new, test_industry_code_new, test_get_trading_dates_code_new, \
test_get_previous_trading_date_code_new, test_get_next_trading_date_code_new, test_get_dividend_code_new

from tests.api.test_api_stock import test_order_shares_code_new, test_order_lots_code_new, \
test_order_value_code_new, \
test_order_percent_code_new, test_order_target_value_code_new

from tests.api.test_api_future import test_buy_open_code_new, test_sell_open_code_new, test_buy_close_code_new, \
test_sell_close_code_new
from tests.api.test_api_base import (
test_get_order_code_new,
test_get_open_order_code_new,
test_cancel_order_code_new,
test_update_universe_code_new,
test_subscribe_code_new,
test_unsubscribe_code_new,
test_get_yield_curve_code_new,
test_history_bars_code_new,
test_all_instruments_code_new,
test_instruments_code_new,
test_sector_code_new,
test_concept_code_new,
test_industry_code_new,
test_get_trading_dates_code_new,
test_get_previous_trading_date_code_new,
test_get_next_trading_date_code_new,
test_get_dividend_code_new,
)

from tests.api.test_api_stock import (
test_order_shares_code_new, test_order_lots_code_new,
test_order_value_code_new,
test_order_percent_code_new, test_order_target_value_code_new,
)

from tests.api.test_api_future import (
test_buy_open_code_new,
test_sell_open_code_new,
test_buy_close_code_new,
test_sell_close_code_new,
)

base_api_config = {
"base": {
Expand Down Expand Up @@ -217,36 +235,42 @@ def test_api():
}

# =================== Test Base API ===================
run(base_api_config, test_get_order_code_new)
run(base_api_config, test_get_open_order_code_new)
run(base_api_config, test_cancel_order_code_new)
run(base_api_config, test_update_universe_code_new)
run(base_api_config, test_subscribe_code_new)
run(base_api_config, test_unsubscribe_code_new)
run(base_api_config, test_get_yield_curve_code_new)
run(base_api_config, test_history_bars_code_new)
run(base_api_config, test_all_instruments_code_new)
run(base_api_config, test_instruments_code_new)
run(base_api_config, test_sector_code_new)
run(base_api_config, test_industry_code_new)
run(base_api_config, test_concept_code_new)
run(base_api_config, test_get_trading_dates_code_new)
run(base_api_config, test_get_previous_trading_date_code_new)
run(base_api_config, test_get_next_trading_date_code_new)
run(base_api_config, test_get_dividend_code_new)
tasks = []

tasks.append((base_api_config, test_get_order_code_new, "test_get_order_code_new"))
tasks.append((base_api_config, test_get_open_order_code_new, "test_get_open_order_code_new"))
tasks.append((base_api_config, test_cancel_order_code_new, "test_cancel_order_code_new"))
tasks.append((base_api_config, test_update_universe_code_new, "test_update_universe_code_new"))
tasks.append((base_api_config, test_subscribe_code_new, "test_subscribe_code_new"))
tasks.append((base_api_config, test_unsubscribe_code_new, "test_unsubscribe_code_new"))
tasks.append((base_api_config, test_get_yield_curve_code_new, "test_get_yield_curve_code_new"))
tasks.append((base_api_config, test_history_bars_code_new, "test_history_bars_code_new"))
tasks.append((base_api_config, test_all_instruments_code_new, "test_all_instruments_code_new"))
tasks.append((base_api_config, test_instruments_code_new, "test_instruments_code_new"))
tasks.append((base_api_config, test_sector_code_new, "test_sector_code_new"))
tasks.append((base_api_config, test_industry_code_new, "test_industry_code_new"))
tasks.append((base_api_config, test_concept_code_new, "test_concept_code_new"))
tasks.append((base_api_config, test_get_trading_dates_code_new, "test_get_trading_dates_code_new"))
tasks.append((base_api_config, test_get_previous_trading_date_code_new, "test_get_previous_trading_date_code_new"))
tasks.append((base_api_config, test_get_next_trading_date_code_new, "test_get_next_trading_date_code_new"))
tasks.append((base_api_config, test_get_dividend_code_new, "test_get_dividend_code_new"))

# =================== Test Stock API ===================
run(stock_api_config, test_order_shares_code_new)
run(stock_api_config, test_order_lots_code_new)
run(stock_api_config, test_order_value_code_new)
run(stock_api_config, test_order_percent_code_new)
run(stock_api_config, test_order_target_value_code_new)
tasks.append((stock_api_config, test_order_shares_code_new, "test_order_shares_code_new"))
tasks.append((stock_api_config, test_order_lots_code_new, "test_order_lots_code_new"))
tasks.append((stock_api_config, test_order_value_code_new, "test_order_value_code_new"))
tasks.append((stock_api_config, test_order_percent_code_new, "test_order_percent_code_new"))
tasks.append((stock_api_config, test_order_target_value_code_new, "test_order_target_value_code_new"))

# =================== Test Future API ===================
run(future_api_config, test_buy_open_code_new)
run(future_api_config, test_sell_open_code_new)
run(future_api_config, test_buy_close_code_new)
run(future_api_config, test_sell_close_code_new)
tasks.append((future_api_config, test_buy_open_code_new, "test_buy_open_code_new"))
tasks.append((future_api_config, test_sell_open_code_new, "test_sell_open_code_new"))
tasks.append((future_api_config, test_buy_close_code_new, "test_buy_close_code_new"))
tasks.append((future_api_config, test_sell_close_code_new, "test_sell_close_code_new"))

for cfg, source_code, name in tasks:
print("running", name)
run(cfg, source_code)

print(u"API test ends.")

Expand Down

0 comments on commit 9d88cad

Please sign in to comment.