def test_get_marker_position_harder(self): tb = TimeBar(100, 100) assert tb.get_marker_postion(0) == 0 assert tb.get_marker_postion(1) == 1 assert tb.get_marker_postion(10) == 10 assert tb.get_marker_postion(20) == 20 assert tb.get_marker_postion(30) == 29 assert tb.get_marker_postion(40) == 39 assert tb.get_marker_postion(50) == 49 assert tb.get_marker_postion(99) == 97 assert tb.get_marker_postion(100) == 98
def test_get_marker_position_small(self): tb = TimeBar(100, 10) assert tb.get_marker_postion(0) == 0 assert tb.get_marker_postion(1) == 0 assert tb.get_marker_postion(10) == 1 assert tb.get_marker_postion(20) == 2 assert tb.get_marker_postion(30) == 2 assert tb.get_marker_postion(40) == 3 assert tb.get_marker_postion(50) == 4 assert tb.get_marker_postion(99) == 8 assert tb.get_marker_postion(100) == 8
def test_get_marker_position_easy(self): tb = TimeBar(100, 102) assert tb.get_marker_postion(0) == 0 assert tb.get_marker_postion(1) == 1 assert tb.get_marker_postion(10) == 10 assert tb.get_marker_postion(20) == 20 assert tb.get_marker_postion(30) == 30 assert tb.get_marker_postion(40) == 40 assert tb.get_marker_postion(50) == 50 assert tb.get_marker_postion(99) == 99 assert tb.get_marker_postion(100) == 100
def test_timebar_with_marker(self): tb = TimeBar(100, 102) assert len(tb.get_timebar(0)) == 102 assert tb.get_timebar(0).index("o") == 1 assert tb.get_timebar( 0 ) == "<o >" assert len(tb.get_timebar(10)) == 102 assert tb.get_timebar(10).index("o") == 11 assert tb.get_timebar( 10 ) == "< o >" assert len(tb.get_timebar(99)) == 102 assert tb.get_timebar(99).index("o") == 100 assert len(tb.get_timebar(100)) == 102 assert tb.get_timebar(100).index("o") == 100
def __init__(self, movie: Movie): """ Player class plays a movie. It also stores the current position. It exposes the all frame numbers in real values. Therefore not encoded. Args: movie (ascii_movie.Movie): Movie Object that the player will play. """ self._movie = movie self._cursor = 0 # virtual cursor pointing to the current frame self._frame_count = 0 self._stopped = False self._clear_screen_setup_done = False for f in self._movie.frames: self._frame_count += f.display_time self.timebar = TimeBar(self._frame_count, self._movie.screen_width)
def test_timebar_with_marker_short(self): tb = TimeBar(100, 8) assert len(tb.get_timebar(0)) == 8 assert tb.get_timebar(0).index("o") == 1 assert tb.get_timebar(0) == "<o >" assert len(tb.get_timebar(10)) == 8 assert tb.get_timebar(10).index("o") == 2 assert tb.get_timebar(10) == "< o >" assert len(tb.get_timebar(50)) == 8 assert tb.get_timebar(50).index("o") == 4 assert tb.get_timebar(50) == "< o >" assert len(tb.get_timebar(99)) == 8 assert tb.get_timebar(99).index("o") == 6 assert tb.get_timebar(99) == "< o>" assert len(tb.get_timebar(100)) == 8 assert tb.get_timebar(100).index("o") == 6 assert tb.get_timebar(100) == "< o>"
def test_empty_timebar(self): tb = TimeBar(0, 10) assert tb._empty_timebar == "< >"
def test_custom_spacer(self): tb = TimeBar(0, 15, spacer=".") assert tb._empty_timebar == "<.............>"
def test_fancy_decorators(self): tb = TimeBar(0, 15, left_decorator=u"*~~*~~", right_decorator=u"Œ") assert tb._empty_timebar == u"*~~*~~ Œ" assert len(tb._empty_timebar) == 15
def test_short_timebar(self): tb = TimeBar(0, 3) assert tb._empty_timebar == "< >"
def test_too_short_timebar(self): with pytest.raises(ValueError) as excinfo: TimeBar(0, 1) assert str( excinfo.values ) == "This TimeBar is too short for these decorators: < o >"
def test_frame_num_larger_than_timebar_frame_count(self): tb = TimeBar(100, 102) bad_frame_timebar = tb.get_timebar(104) assert len(bad_frame_timebar) == 102 assert bad_frame_timebar == "< o>"
def test_long_timebar(self): tb = TimeBar(0, 100) assert tb._empty_timebar == "< " \ " " \ " >"