示例#1
0
 def test_instantiate_new(self, ConnectionMock):
     pl = playlist.Playlist(name='My Playlist',
                            type=enums.PlaylistTypeEnum.EXPLICIT)
     pl.video_ids = TEST_VIDEO_IDS
     self.assertEquals(pl.id, None)
     self.assertEquals(pl.name, 'My Playlist')
     self.assertEquals(pl.type, enums.PlaylistTypeEnum.EXPLICIT)
     self.assertEquals(pl.video_ids, TEST_VIDEO_IDS)
     self.assertEquals(pl.short_description, None)
示例#2
0
 def test_instantiate_with_reference_id(self, ConnectionMock):
     m = ConnectionMock()
     m.get_item.return_value = {
         'id': TEST_PLAYLIST_ID,
         'name': '',
         'shortDescription': '',
         'referenceId': TEST_PLAYLIST_REF_ID,
         'thumbnailURL': '',
         'videoIds': [],
         'playlistType': ''
     }
     pl = playlist.Playlist(reference_id=TEST_PLAYLIST_REF_ID)
     self.assertEquals(pl.id, TEST_PLAYLIST_ID)
示例#3
0
 def test_save_new(self, ConnectionMock):
     m = self._get_list_mock(ConnectionMock)
     m.post.return_value = 10
     pl = playlist.Playlist(name="Unit Test Videos",
                            type=enums.PlaylistTypeEnum.EXPLICIT)
     for v in video.Video.find_by_tags(and_tags=[
             'unittest',
     ]):
         pl.videos.append(v)
     pl.save()
     self.assertEquals(pl.id, 10)
     self.assertEquals(pl.name, 'Unit Test Videos')
     self.assertEquals(m.method_calls[0][0], 'get_list')
     self.assertEquals(m.method_calls[0][1][0], 'find_videos_by_tags')
     self.assertEquals(m.method_calls[1][0], 'post')
     self.assertEquals(m.method_calls[1][1][0], 'create_playlist')
示例#4
0
 def test_save_update(self, ConnectionMock):
     m = ConnectionMock()
     data = {}
     data['id'] = TEST_PLAYLIST_ID
     data['referenceId'] = TEST_PLAYLIST_REF_ID
     data['name'] = "test-%s" % self.test_uuid
     data['shortDescription'] = "My description"
     data['thumbnailURL'] = "http://google.com"
     data['videoIds'] = TEST_VIDEO_IDS
     data['playlistType'] = enums.PlaylistTypeEnum.EXPLICIT
     m.get_item.return_value = data
     m.post.return_value = data
     pl = playlist.Playlist(id=TEST_PLAYLIST_ID)
     pl.name = 'test-%s' % self.test_uuid
     pl.save()
     self.assertEquals(pl.id, TEST_PLAYLIST_ID)
     self.assertEquals(pl.name, 'test-%s' % self.test_uuid)
     self.assertEquals(m.method_calls[0][0], 'get_item')
     self.assertEquals(m.method_calls[0][1][0], 'find_playlist_by_id')
     self.assertEquals(m.method_calls[1][0], 'post')
     self.assertEquals(m.method_calls[1][1][0], 'update_playlist')
示例#5
0
 def test_instantiate_with_invalid_parameters(self, ConnectionMock):
     try:
         pl = playlist.Playlist(name="No type specified")
         self.fail('Should have raised an error.')
     except exceptions.PyBrightcoveError, e:
         self.assertEquals(str(e), 'Invalid parameters for Playlist.')