Ejemplo n.º 1
0
 def test_init(self):
     static_content = movement.StaticContent(50)
     assert static_content.x_offset is None
     assert static_content.y_offset is None
     assert static_content.elapsed_time is None
     assert static_content.total_duration == 50
     assert static_content.extra_time_after_end is None
Ejemplo n.º 2
0
def deserialise_StaticContent(
    static_content: departure_pb2.StaticContent,
) -> movement.StaticContent:
    return movement.StaticContent(
        total_duration=static_content.total_duration,
        x_offset_init=static_content.x_offset_init,
        y_offset_init=static_content.y_offset_init,
    )
Ejemplo n.º 3
0
 def test_end_reached(self):
     static_content = movement.StaticContent(10, 2, 3)
     static_content.reset()
     assert not static_content.update(23)
     assert static_content.end_of_segment_reached
     assert static_content.x_offset == 2
     assert static_content.y_offset == 3
     assert static_content.total_duration == 10
     assert static_content.elapsed_time == 10
     assert static_content.extra_time_after_end == 13
Ejemplo n.º 4
0
 def test_reset(self):
     static_content = movement.StaticContent(10, 6, 7)
     static_content.set_offset(3, 4)
     static_content.reset()
     assert static_content.x_offset == 6
     assert static_content.y_offset == 7
     assert static_content.total_duration == 10
     assert static_content.elapsed_time == 0
     assert static_content.extra_time_after_end == 0
     assert not static_content.end_of_segment_reached
Ejemplo n.º 5
0
    def test_at_1_before_total_duration_add_1(self):
        static_content = movement.StaticContent(10, 2, 3)
        static_content.reset()
        assert not static_content.update(9)  # 1 before end
        assert not static_content.end_of_segment_reached

        assert not static_content.update(1)  # add 1
        assert static_content.end_of_segment_reached  # this has changed
        assert static_content.extra_time_after_end == 0

        assert not static_content.update(1)  # add 1
        assert static_content.end_of_segment_reached  # still True
        assert static_content.extra_time_after_end == 1
Ejemplo n.º 6
0
    def test_update_movement(self):
        movement1 = movement.NoMovement()
        movement2 = movement.StaticContent(0)
        board_section = board.BoardSection(
            0,
            0,
            8,
            8,
            board.BoardSectionContent([(0, 0, (255, 255, 255))], 8, 8),
            movement=movement1,
        )

        board_section.reset()
        _ = board_section.pixels()

        assert board_section._movement == movement1
        assert not board_section._has_changed

        board_section.update_movement(movement2)

        assert board_section._movement == movement2
        assert board_section._has_changed
Ejemplo n.º 7
0
 def test_set_offset(self):
     static_content = movement.StaticContent(10, 2, 3)
     static_content.reset()
     static_content.set_offset(4, 5)
     assert static_content.x_offset == 4
     assert static_content.y_offset == 5
Ejemplo n.º 8
0
 def setup_method(self):
     self.tracker = movement.MovementCycle([
         movement.StaticContent(200),
         movement.ScrollingContent(15, 4, -1, 0)
     ])
Ejemplo n.º 9
0
 def test_update_no_reset(self):
     static_content = movement.StaticContent(0)
     with pytest.raises(movement.MovementException):
         static_content.update(20)