Esempio n. 1
0
    def test_create_new_frame_call__gap(self, mocker):
        fs = FrameSetFactory(unit=Unit.SECOND, unit_quantity=10)
        create_new_frame_mock = mocker.patch.object(fs,
                                                    "create_new_frame",
                                                    wraps=fs.create_new_frame)
        current_last_tick = TickFactory()
        current_frame = FrameFactory(
            first_tick=current_last_tick,
            period_start=arrow.get("2020-01-01 12:34:10"),
            period_end=arrow.get("2020-01-01 12:34:20"),
        )
        fs.frames = [current_frame]

        new_tick = TickFactory(datetime=arrow.get("2020-01-01 12:34:56"))
        fs.on_new_tick(new_tick)

        assert create_new_frame_mock.call_args_list == [
            call(
                current_last_tick,
                arrow.get("2020-01-01 12:34:20"),
                arrow.get("2020-01-01 12:34:30"),
            ),
            call(
                current_last_tick,
                arrow.get("2020-01-01 12:34:30"),
                arrow.get("2020-01-01 12:34:40"),
            ),
            call(
                current_last_tick,
                arrow.get("2020-01-01 12:34:40"),
                arrow.get("2020-01-01 12:34:50"),
            ),
            call(
                new_tick,
                arrow.get("2020-01-01 12:34:50"),
                arrow.get("2020-01-01 12:35:00"),
            ),
        ]
Esempio n. 2
0
    def test_exists(self):
        fs = FrameSetFactory()
        last_frame = FrameFactory()
        fs.frames = ["first", last_frame]

        assert fs.current == last_frame