def test_index_download_update(): mng = moex.Index(db="test") # noinspection PyProtectedMember data = mng._download(INDEX, pd.Timestamp("2019-09-13")) assert isinstance(data, list) assert len(data) >= 1 assert data[0] == {"CLOSE": 4400.91, "DATE": pd.Timestamp("2019-09-13")}
def test_index(): mng = moex.Index(db="test") df = mng[INDEX] assert isinstance(df, pd.DataFrame) assert len(df) > 3750 assert df.columns == [CLOSE] assert df.index[0] == pd.Timestamp("2003-02-26") assert df.loc["2003-02-26", CLOSE] == 335.67 assert df.loc["2018-03-02", CLOSE] == 3273.16 assert df.loc["2018-12-24", CLOSE] == 3492.91
def test_index_wrong_id(): mng = moex.Index(db="test") with pytest.raises(POptimizerError) as error: # noinspection PyStatementEffect mng["QQQ"] assert "Отсутствуют данные test.misc.QQQ" == str(error.value)