[2acc11]: script.module.brightcove / tests / test_api.py  Maximize  Restore  History

Download this file

105 lines (86 with data), 4.2 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
import unittest2
from unittest2 import TestCase
from brightcove.api import Brightcove
from brightcove.objects import Video, Playlist, VideoItemCollection, PlaylistItemCollection
from tests import utils
class TestBrightcove(TestCase):
def test_init(self):
b = Brightcove('xxx')
self.assertEqual(b.token, 'xxx')
class TestVideoApis(utils.MockHTTPTestCase):
def test_find_video_by_id(self):
video_id = 1809541469
v = self.b.find_video_by_id(video_id)
self.assertEqual(video_id, v.id)
self.assertIsInstance(v, Video)
def test_find_videos_by_ids(self):
videoid1 = 1809541469
videoid2 = 1809586449
videos = self.b.find_videos_by_ids([videoid1, videoid2])
self.assertIsInstance(videos, VideoItemCollection)
self.assertIsInstance(videos.items[0], Video)
self.assertEqual(videos.items[0].id, videoid1)
self.assertIsInstance(videos.items[1], Video)
self.assertEqual(videos.items[0].id, videoid1)
def test_find_video_by_reference_id(self):
refid = 1194817110596
v = self.b.find_video_by_reference_id(refid)
self.assertIsInstance(v, Video)
def test_find_videos_by_reference_ids(self):
refid1 = '1194817110596'
refid2 = '1194817110591'
videos = self.b.find_videos_by_reference_ids([refid1, refid2])
self.assertIsInstance(videos, VideoItemCollection)
self.assertIsInstance(videos.items[0], Video)
self.assertIsInstance(videos.items[1], Video)
def test_find_all_videos(self):
videos = self.b.find_all_videos()
self.assertIsInstance(videos, VideoItemCollection)
self.assertIsInstance(videos.items[0], Video)
self.assertIsInstance(videos.items[1], Video)
def test_find_modified_videos(self):
videos = self.b.find_modified_videos(20380320)
self.assertIsInstance(videos, VideoItemCollection)
self.assertIsInstance(videos.items[0], Video)
self.assertIsInstance(videos.items[1], Video)
def test_find_related_videos(self):
videos = self.b.find_related_videos(video_id=1809541469)
self.assertIsInstance(videos, VideoItemCollection)
self.assertIsInstance(videos.items[0], Video)
self.assertIsInstance(videos.items[1], Video)
def test_search_videos(self):
videos = self.b.search_videos(all='Obama')
self.assertIsInstance(videos, VideoItemCollection)
self.assertIsInstance(videos.items[0], Video)
self.assertIsInstance(videos.items[1], Video)
## Playlist tests
def test_find_playlist_by_id(self):
playlist_id = 49934418001
playlist = self.b.find_playlist_by_id(playlist_id)
self.assertIsInstance(playlist, Playlist)
self.assertEqual(playlist.id, playlist_id)
def test_find_playlists_by_ids(self):
playlist1_id = 49934418001
playlist2_id = 1811464211
playlists = self.b.find_playlists_by_ids([playlist1_id, playlist2_id])
self.assertIsInstance(playlists, PlaylistItemCollection)
self.assertIsInstance(playlists.items[0], Playlist)
self.assertEqual(playlists.items[0].id, playlist1_id)
self.assertIsInstance(playlists.items[1], Playlist)
self.assertEqual(playlists.items[1].id, playlist2_id)
def test_find_playlist_by_reference_id(self):
refid = 1194811622205
playlist = self.b.find_playlist_by_reference_id(refid)
self.assertIsInstance(playlist, Playlist)
def test_find_playlists_by_reference_ids(self):
refid1 = '1194811622205'
refid2 = '1194811622271'
playlists = self.b.find_playlists_by_reference_ids([refid1, refid2])
self.assertIsInstance(playlists, PlaylistItemCollection)
self.assertIsInstance(playlists.items[0], Playlist)
self.assertIsInstance(playlists.items[1], Playlist)
def test_find_all_playlists(self):
playlists = self.b.find_all_playlists()
self.assertIsInstance(playlists, PlaylistItemCollection)
self.assertIsInstance(playlists.items[0], Playlist)
self.assertIsInstance(playlists.items[1], Playlist)

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks