mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-12 12:22:35 +00:00
* modify path for etf, options, insider * fix small * change path for stocks screener * fix flake 8 * remove preset_path * black * fix * fix tests * fix tests * fix flake8 * change paths_helper load * put ns parser back Co-authored-by: minhhoang1023 <40023817+minhhoang1023@users.noreply.github.com>
137 lines
3.4 KiB
Python
137 lines
3.4 KiB
Python
# IMPORTATION STANDARD
|
|
|
|
# IMPORTATION THIRDPARTY
|
|
import pytest
|
|
|
|
# IMPORTATION INTERNAL
|
|
from openbb_terminal.stocks.insider import openinsider_model
|
|
|
|
|
|
@pytest.mark.vcr(record_mode="none")
|
|
@pytest.mark.parametrize(
|
|
"val",
|
|
[1, -1],
|
|
)
|
|
def test_check_valid_range(recorder, val):
|
|
error_text = openinsider_model.check_valid_range(
|
|
category="General",
|
|
field="SharePriceMin",
|
|
val=val,
|
|
min_range=0,
|
|
max_range=9999,
|
|
)
|
|
recorder.capture(error_text)
|
|
|
|
|
|
@pytest.mark.vcr(record_mode="none")
|
|
@pytest.mark.parametrize(
|
|
"d_date",
|
|
[
|
|
{
|
|
"FilingDate": "MOCK_INVALID_DATE",
|
|
"TradingDate": "MOCK_INVALID_DATE",
|
|
},
|
|
{
|
|
"FilingDate": "All dates",
|
|
"FilingDateFrom": "",
|
|
"FilingDateTo": "",
|
|
"TradingDate": "All dates",
|
|
"TradingDateFrom": "",
|
|
"TradingDateTo": "",
|
|
"FilingDelayMin": "",
|
|
"FilingDelayMax": "",
|
|
"NDaysAgo": "",
|
|
},
|
|
{
|
|
"FilingDate": "Custom",
|
|
"FilingDateFrom": "",
|
|
"FilingDateTo": "",
|
|
"TradingDate": "Custom",
|
|
"TradingDateFrom": "",
|
|
"TradingDateTo": "",
|
|
"FilingDelayMin": "",
|
|
"FilingDelayMax": "",
|
|
"NDaysAgo": "",
|
|
},
|
|
],
|
|
)
|
|
def test_check_dates(recorder, d_date):
|
|
error_text = openinsider_model.check_dates(d_date=d_date)
|
|
recorder.capture(error_text)
|
|
|
|
|
|
@pytest.mark.vcr(record_mode="none")
|
|
@pytest.mark.parametrize(
|
|
"multiple, val",
|
|
[(2, "4"), (1, "a")],
|
|
)
|
|
def test_check_valid_multiple(multiple, val, recorder):
|
|
error_text = openinsider_model.check_valid_multiple(
|
|
category="TransactionFiling",
|
|
field="TradedMinK",
|
|
val=val,
|
|
multiple=multiple,
|
|
)
|
|
recorder.capture(error_text)
|
|
|
|
|
|
@pytest.mark.vcr(record_mode="none")
|
|
@pytest.mark.parametrize(
|
|
"l_possible_vals, val",
|
|
[
|
|
([1, 2], "1"),
|
|
([1, 2], "3"),
|
|
],
|
|
)
|
|
def test_check_int_in_list(l_possible_vals, val, recorder):
|
|
error_text = openinsider_model.check_int_in_list(
|
|
category="Others",
|
|
field="MaxResults",
|
|
val=val,
|
|
l_possible_vals=l_possible_vals,
|
|
)
|
|
recorder.capture(error_text)
|
|
|
|
|
|
@pytest.mark.vcr(record_mode="none")
|
|
@pytest.mark.parametrize(
|
|
"d_company_totals",
|
|
[
|
|
{
|
|
"FilingsMin": "",
|
|
"FilingsMax": "",
|
|
"InsidersMin": "",
|
|
"InsidersMax": "",
|
|
"OfficersMin": "",
|
|
"OfficersMax": "",
|
|
"TradedMinK": "",
|
|
"TradedMaxK": "",
|
|
"OwnChangeMinPct": "",
|
|
"OwnChangeMaxPct": "",
|
|
},
|
|
],
|
|
)
|
|
def test_check_open_insider_company_totals(d_company_totals, recorder):
|
|
error_text = openinsider_model.check_open_insider_company_totals(
|
|
d_company_totals=d_company_totals
|
|
)
|
|
recorder.capture(error_text)
|
|
|
|
|
|
@pytest.mark.vcr(record_mode="none")
|
|
def test_get_open_insider_link(recorder):
|
|
link = openinsider_model.get_open_insider_link(preset_loaded="template.ini")
|
|
recorder.capture(link)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
def test_get_open_insider_data(recorder):
|
|
ticker = "TSLA"
|
|
link = f"http://openinsider.com/screener?s={ticker}"
|
|
data_df = openinsider_model.get_open_insider_data(
|
|
url=link,
|
|
has_company_name=bool(not ticker),
|
|
)
|
|
|
|
recorder.capture(data_df)
|