示例#1
0
class TestOoyalaAPI(object):
    def setUp(self):
        self.api = OoyalaAPI('lueDYyOlaYtIydG6Fr_En9pHWL1p.Y-sBm',
                             'KXKXf5-EKmwg3gmuybr52fD8IRTJaXuGX0O5CrFm')

    def get_all_assets(self):
        # Get all assets
        try:
            res = self.api.get('assets')
            print "all assests {0}".format(res)
        except:
            self.get_all_assets()

    def get_asset(self, asset_id):
        # Get all assets
        try:
            res = self.api.get('assets/' + asset_id)
            print "assest id {0} details {1}".format(asset_id, res)
        except:
            self.get_asset(asset_id)

    def update_asset(self, asset_id, asset_key, asset_value):
        try:
            res = self.api.patch('assets/' + asset_id,
                                 {asset_key: asset_value})
            print "after patch {0}".format(res)
        except:
            self.update_asset(asset_id, asset_key, asset_value)
示例#2
0
 def setUp(self):
     self.api = OoyalaAPI('lueDYyOlaYtIydG6Fr_En9pHWL1p.Y-sBm',
                          'KXKXf5-EKmwg3gmuybr52fD8IRTJaXuGX0O5CrFm')
示例#3
0
class TestOoyalaAPI(unittest.TestCase):
    def setUp(self):
        self.api = OoyalaAPI('lueDYyOlaYtIydG6Fr_En9pHWL1p.Y-sBm',
                             'KXKXf5-EKmwg3gmuybr52fD8IRTJaXuGX0O5CrFm')

    def test_get(self):
        # Get all assets
        res = self.api.get('assets')
        print res
        #self.assertIsNotNone(res, 'Response should not be None')
        #self.assertTrue(len(res)>0, 'Response string should be non-empty')

    def test_post(self):
        # Create a new channel
        res = self.api.post('assets', 
                            {"name": "My new channel","asset_type": "channel"})
        self.assertTrue(res['embed_code'], 'embed_code should be present')
    
        # Delete create asset
        path = 'assets/' + res['embed_code']
        res = self.api.delete(path)
        self.assertTrue(res, 'Response should be True')
    
    def test_put(self):
        # Create a new channel
        res = self.api.post('assets',
                            {"name": "My new channel","asset_type": "channel"})
        channel_id = res['embed_code'] # Get channel id
    
        # Create a new video
        res = self.api.post('assets', 
                            {"name": "My asset on YouTube","asset_type": "youtube","youtube_id": "yyNqLNX02CU"})
        video_id = res['embed_code'] # Get channel id
    
        #Set a new line-up through a PUT request
        path  = 'assets/%s/lineup' % channel_id
        res = self.api.put(path, [video_id])
    
        # Remove channel and video assets
        self.assertTrue(self.api.delete('assets/%s' % channel_id))
        self.assertTrue(self.api.delete('assets/%s' % video_id))
    
    def test_patch(self):
        #create a new video
        res = self.api.post('assets',
                            {"name": "My asset on YouTube","asset_type": "youtube","youtube_id": "yyNqLNX02CU"})
    
        video_id = res['embed_code'] # Get channel id
    
        #change the video's name 
        res = self.api.patch('assets/%s' % video_id,
                             {"name":"new asset name"})
    
        # Remove channel and video assets
        self.assertTrue(self.api.delete('assets/%s' % video_id))

    def runTest(self):
        self.test_get()
        self.test_post()
        self.test_patch()
        self.test_put()
示例#4
0
 def setUp(self):
     self.api = OoyalaAPI('lueDYyOlaYtIydG6Fr_En9pHWL1p.Y-sBm',
                          'KXKXf5-EKmwg3gmuybr52fD8IRTJaXuGX0O5CrFm')
示例#5
0
 def setUp(self):
     self.api = OoyalaAPI('',
                          '')