def test_tracks_append_attaches_layer(self, mocker): movie = Movie(1, 1) layer = Layer(1.0) spy = mocker.spy(layer, 'attach') movie.tracks.append((0.0, layer)) spy.assert_called_once_with(movie)
def test_add_layer_attaches_layer(self, mocker): movie = Movie(1, 1) layer = Layer(1.0) spy = mocker.spy(layer, 'attach') movie.add_layer(0.0, layer) spy.assert_called_once_with(movie)
def test_frame_calls_layer_start(self, mocker): movie = Movie(1, 1) layer = Layer(1.0) movie.add_layer(0.0, layer) spy = mocker.spy(layer, 'start') movie._frame(0.0) spy.assert_called_once()
def test_remove_layer_detaches_layer(self, mocker): movie = Movie(1, 1) layer = Layer(1.0) movie.add_layer(0.0, layer) spy = mocker.spy(layer, 'detach') movie.remove_layer(layer) spy.assert_called_once()
def test_frame_calls_layer_frame(self, mocker): movie = Movie(1, 1) layer = Layer(1.0) movie.add_layer(0.0, layer) spy = mocker.spy(layer, 'frame') for time in (0.0, 0.3, 0.9): movie._frame(time) spy.assert_called_with(time) spy.reset_mock()
def test_tracks_filter_detaches_layer(self, mocker): movie = Movie(1, 1) test_layer = Layer(1.0) movie.add_layer(0.0, test_layer) spy = mocker.spy(test_layer, 'detach') movie.tracks = [(time, layer) for time, layer in movie.tracks if layer != test_layer] spy.assert_called_once()
def test_screenshot_can_save_to_path(self): movie = Movie(1, 1) layer = Layer(1.0) movie.add_layer(0.0, layer) movie.screenshot(0.0, 'screenshot.png') assert np.array_equal( imread('screenshot.png'), np.array([[[0, 0, 0, 255]]])) os.remove(os.path.join(os.getcwd(), 'screenshot.png'))
def test_screenshot_can_write_to_stream(self): movie = Movie(1, 1) layer = Layer(1.0) movie.add_layer(0.0, layer) stream = io.BytesIO() movie.screenshot(0.0, filename='screenshot.png', file=stream) movie.screenshot(0.0, 'screenshot.png') stream.seek(0) with open('screenshot.png', 'rb') as file: assert file.read() == stream.read() os.remove(os.path.join(os.getcwd(), 'screenshot.png'))