def test_sync_cfy_error(self):
        register_uris(httpretty, cfy_post_bundle_error=True)

        bridge = ClarifyBrightcoveBridge(self.clarify_client, self.brightcove_client)
        self.assertIsNotNone(bridge)
        with self.assertRaises(clarify.APIException):
            bridge.sync_bundles()
 def test_sync_metadata_synced(self):
     register_uris(httpretty, metadata_synced=True)
     bridge = ClarifyBrightcoveBridge(self.clarify_client, self.brightcove_client)
     self.assertIsNotNone(bridge)
     bridge.sync_bundles()
     bridge.log_sync_stats()
     latest_requests = httpretty.httpretty.latest_requests
     self.assertEqual(len(latest_requests), 8)
     self.assertEqual(bridge.sync_stats['created'], 1)
     self.assertEqual(bridge.sync_stats['updated'], 0)
     self.assertEqual(bridge.sync_stats['deleted'], 1)
     self.assertEqual(bridge.sync_stats['count'], 2)
    def test_sync_bc_errors(self):
        register_uris(httpretty, bc_videos_auth_error=True, bc_videos_throttle=True)

        bridge = ClarifyBrightcoveBridge(self.clarify_client, self.brightcove_client)
        self.assertIsNotNone(bridge)
        bridge.sync_bundles()
        bridge.log_sync_stats()
        latest_requests = httpretty.httpretty.latest_requests
        self.assertEqual(len(latest_requests), 12)
        self.assertEqual(bridge.sync_stats['created'], 1)
        self.assertEqual(bridge.sync_stats['updated'], 1)
        self.assertEqual(bridge.sync_stats['deleted'], 1)
        self.assertEqual(bridge.sync_stats['count'], 2)
    def test_sync_no_delete(self):
        register_uris(httpretty)
        bridge = ClarifyBrightcoveBridge(self.clarify_client, self.brightcove_client)
        self.assertIsNotNone(bridge)

        def confirm_delete(name, video_id):
            return False

        bridge.sync_bundles(confirm_delete_fun=confirm_delete)
        bridge.log_sync_stats()
        latest_requests = httpretty.httpretty.latest_requests
        self.assertEqual(len(latest_requests), 8)
        self.assertEqual(bridge.sync_stats['created'], 1)
        self.assertEqual(bridge.sync_stats['updated'], 1)
        self.assertEqual(bridge.sync_stats['deleted'], 0)
        self.assertEqual(bridge.sync_stats['count'], 3)