Esempio n. 1
0
    def test_clean_old_frames(self, mock_clean_old_frames):
        tick = TickFactory()
        period_start = arrow.get("2020-01-01 12:35:00")

        fs = FrameSetFactory()
        fs.create_new_frame(tick=tick, period_start=period_start)

        assert mock_clean_old_frames.call_args_list == [call()]
Esempio n. 2
0
    def test_add_to_frames(self, mocker):
        mocker.patch(f"{CLASS_FRAME_DEFINITION_PATH}",
                     return_value="my_new_frame")

        tick = TickFactory()
        period_start = arrow.get("2020-01-01 12:35:00")
        fs = FrameSetFactory()
        fs.create_new_frame(tick=tick, period_start=period_start)

        assert fs.frames == ["my_new_frame"]
Esempio n. 3
0
    def test_frame_init__minimal(self, mock_frame_init):
        tick = TickFactory()
        period_start = arrow.get("2020-01-01 12:35:00")

        fs = FrameSetFactory()
        fs.create_new_frame(tick=tick, period_start=period_start)

        assert mock_frame_init.call_args_list == [
            call(
                parent_frameset=fs,
                first_tick=tick,
                period_start=period_start,
                period_end=None,
                previous_frame=None,
            )
        ]
Esempio n. 4
0
    def test_set_new_as_current_next(self, mocker):
        mock_current = mocker.Mock()
        mocker.patch(
            f"{CLASS_DEFINITION_PATH}.current",
            new_callable=lambda: mock_current,
        )

        mocker.patch(f"{CLASS_FRAME_DEFINITION_PATH}",
                     return_value="my_new_frame")

        tick = TickFactory()
        period_start = arrow.get("2020-01-01 12:35:00")
        fs = FrameSetFactory()
        fs.create_new_frame(tick=tick, period_start=period_start)

        assert mock_current.next_frame == "my_new_frame"
Esempio n. 5
0
    def test_previous_frame(self, mocker, mock_frame_init):
        mock_current = mocker.Mock()
        mock_current.next_frame = None
        mocker.patch(
            f"{CLASS_DEFINITION_PATH}.current",
            new_callable=lambda: mock_current,
        )

        tick = TickFactory()
        period_start = arrow.get("2020-01-01 12:35:00")

        fs = FrameSetFactory()
        fs.create_new_frame(tick=tick, period_start=period_start)

        assert mock_frame_init.call_args_list == [
            call(
                parent_frameset=fs,
                first_tick=tick,
                period_start=period_start,
                period_end=None,
                previous_frame=mock_current,
            )
        ]