def test_insert_should_insert_playlist(self): playlists = Playlists() service = MagicMock() service.playlists = MagicMock(return_value=playlists) execute = MagicMock() execute.execute = MagicMock() playlists.insert = MagicMock(return_value=execute) store = PlaylistStore(service) store.insert('title', ['1234']) execute.execute.assert_called_once_with()
def test_insert_videos(self): playlists = Playlists() playlists.insert = MagicMock() service = MagicMock() service.playlists = MagicMock(return_value=playlists) service.playlistItems = MagicMock() store = PlaylistStore(service) store.insert('title', ['123456', '321']) assert service.playlistItems.call_count == 2
def test_insert_playlist_parameters(self): service = MagicMock() playlists = Playlists() playlists.insert = MagicMock() service.playlists = MagicMock(return_value=playlists) store = PlaylistStore(service) title = '2015-08-27' store.insert(title, ['123']) playlists.insert.assert_called_once_with(part='snippet, status, id', body={ 'snippet': { 'title': title }, 'status': { 'privacyStatus': 'private' } })
def test_insert_no_videos(self): with pytest.raises(AssertionError) as e: store = PlaylistStore({}) store.insert('title', []) assert 'No video\'s to insert into playlist' in str(e)