예제 #1
0
class DivExt(base.AbstractTable[events.UpdateDivCommand]):
    """Таблица со сводными данными по дивидендам из внешних источников."""

    group: ClassVar[ports.GroupName] = ports.DIV_EXT
    _gateways: Final[tuple[GateWayDesc, ...]] = (
        GateWayDesc("Dohod", col.ORDINARY, dohod.DohodGateway()),
        GateWayDesc("Dohod", col.PREFERRED, dohod.DohodGateway()),
        GateWayDesc("Conomy", col.ORDINARY, conomy.ConomyGateway()),
        GateWayDesc("Conomy", col.PREFERRED, conomy.ConomyGateway()),
        GateWayDesc("BCS", col.ORDINARY, bcs.BCSGateway()),
        GateWayDesc("BCS", col.PREFERRED, bcs.BCSGateway()),
        GateWayDesc("NASDAQ", col.FOREIGN, nasdaq.NASDAQGateway()),
        # GateWayDesc("FinRange", col.ORDINARY, finrange.FinRangeGateway()),
        # GateWayDesc("FinRange", col.FOREIGN, finrange.FinRangeGateway()),
        GateWayDesc("Close", col.ORDINARY, close_reestry.CloseGateway()),
        GateWayDesc("Close", col.PREFERRED, close_reestry.CloseGateway()),
        GateWayDesc("InvestMint", col.ORDINARY,
                    invest_mint.InvestMintGateway()),
        GateWayDesc("InvestMint", col.PREFERRED,
                    invest_mint.InvestMintGateway()),
        GateWayDesc("InvestMint", col.FOREIGN,
                    invest_mint.InvestMintGateway()),
    )

    def _update_cond(self, event: events.UpdateDivCommand) -> bool:
        """Если данные отсутствуют, то их надо загрузить, а так же обновить раз в неделю."""
        if (timestamp := self._timestamp) is None:
            return True

        return datetime.utcnow() - timestamp > timedelta(days=7)
예제 #2
0
async def test_loader_get_html_error(mocker):
    """Регрессионный тест при ошибке загрузки данных из интернета."""
    mocker.patch.object(invest_mint.parser, "get_html", side_effect=description.ParserError())

    loader = invest_mint.InvestMintGateway()
    df = await loader("BELU")

    assert df is None
예제 #3
0
async def test_loader(mocker, df, html, df_rez):
    """Форматирование данных."""
    mocker.patch.object(invest_mint.parser, "get_html", return_value=html)
    mocker.patch.object(invest_mint.parser, "get_df_from_html", return_value=df.copy())

    gw = invest_mint.InvestMintGateway()

    pd.testing.assert_frame_equal(await gw("BELU"), df_rez)
예제 #4
0
async def test_loader_get_df_from_html_error(mocker):
    """Регрессионный тест при парсинге данных."""
    mocker.patch.object(invest_mint.parser, "get_html", return_value="")
    mocker.patch.object(invest_mint.parser, "get_df_from_html", side_effect=description.ParserError())

    loader = invest_mint.InvestMintGateway()
    df = await loader("BELU")

    assert df is None