class CloudVideoIntelligenceHookTestCase(unittest.TestCase): def setUp(self): with mock.patch( "airflow.contrib.hooks.gcp_video_intelligence_hook.CloudVideoIntelligenceHook.__init__", new=mock_base_gcp_hook_default_project_id, ): self.hook = CloudVideoIntelligenceHook(gcp_conn_id="test") @mock.patch( "airflow.contrib.hooks.gcp_video_intelligence_hook.CloudVideoIntelligenceHook.get_conn" ) def test_annotate_video(self, get_conn): # Given annotate_video_method = get_conn.return_value.annotate_video get_conn.return_value.annotate_video.return_value = ANNOTATE_VIDEO_RESPONSE # When result = self.hook.annotate_video(input_uri=INPUT_URI, features=FEATURES) # Then self.assertIs(result, ANNOTATE_VIDEO_RESPONSE) annotate_video_method.assert_called_once_with( input_uri=INPUT_URI, input_content=None, features=FEATURES, video_context=None, output_uri=None, location_id=None, retry=None, timeout=None, metadata=None, ) @mock.patch( "airflow.contrib.hooks.gcp_video_intelligence_hook.CloudVideoIntelligenceHook.get_conn" ) def test_annotate_video_with_output_uri(self, get_conn): # Given annotate_video_method = get_conn.return_value.annotate_video get_conn.return_value.annotate_video.return_value = ANNOTATE_VIDEO_RESPONSE # When result = self.hook.annotate_video(input_uri=INPUT_URI, output_uri=OUTPUT_URI, features=FEATURES) # Then self.assertIs(result, ANNOTATE_VIDEO_RESPONSE) annotate_video_method.assert_called_once_with( input_uri=INPUT_URI, output_uri=OUTPUT_URI, input_content=None, features=FEATURES, video_context=None, location_id=None, retry=None, timeout=None, metadata=None, )
class CloudVideoIntelligenceHookTestCase(unittest.TestCase): def setUp(self): with mock.patch( "airflow.contrib.hooks.gcp_video_intelligence_hook.CloudVideoIntelligenceHook.__init__", new=mock_base_gcp_hook_default_project_id, ): self.hook = CloudVideoIntelligenceHook(gcp_conn_id="test") @mock.patch("airflow.contrib.hooks.gcp_video_intelligence_hook.CloudVideoIntelligenceHook.get_conn") def test_annotate_video(self, get_conn): # Given annotate_video_method = get_conn.return_value.annotate_video get_conn.return_value.annotate_video.return_value = ANNOTATE_VIDEO_RESPONSE # When result = self.hook.annotate_video(input_uri=INPUT_URI, features=FEATURES) # Then self.assertIs(result, ANNOTATE_VIDEO_RESPONSE) annotate_video_method.assert_called_once_with( input_uri=INPUT_URI, input_content=None, features=FEATURES, video_context=None, output_uri=None, location_id=None, retry=None, timeout=None, metadata=None, ) @mock.patch("airflow.contrib.hooks.gcp_video_intelligence_hook.CloudVideoIntelligenceHook.get_conn") def test_annotate_video_with_output_uri(self, get_conn): # Given annotate_video_method = get_conn.return_value.annotate_video get_conn.return_value.annotate_video.return_value = ANNOTATE_VIDEO_RESPONSE # When result = self.hook.annotate_video(input_uri=INPUT_URI, output_uri=OUTPUT_URI, features=FEATURES) # Then self.assertIs(result, ANNOTATE_VIDEO_RESPONSE) annotate_video_method.assert_called_once_with( input_uri=INPUT_URI, output_uri=OUTPUT_URI, input_content=None, features=FEATURES, video_context=None, location_id=None, retry=None, timeout=None, metadata=None, )
def execute(self, context): hook = CloudVideoIntelligenceHook(gcp_conn_id=self.gcp_conn_id) operation = hook.annotate_video( input_uri=self.input_uri, input_content=self.input_content, video_context=self.video_context, location=self.location, retry=self.retry, features=[enums.Feature.LABEL_DETECTION], ) self.log.info("Processing video for label annotations") result = MessageToDict(operation.result()) self.log.info("Finished processing.") return result
def execute(self, context): hook = CloudVideoIntelligenceHook(gcp_conn_id=self.gcp_conn_id) operation = hook.annotate_video( input_uri=self.input_uri, input_content=self.input_content, video_context=self.video_context, location=self.location, retry=self.retry, features=[enums.Feature.LABEL_DETECTION], ) self.log.info("Processing video for label annotations") result = MessageToDict(operation.result()) self.log.info("Finished processing.") return result
def setUp(self): with mock.patch( "airflow.contrib.hooks.gcp_video_intelligence_hook.CloudVideoIntelligenceHook.__init__", new=mock_base_gcp_hook_default_project_id, ): self.hook = CloudVideoIntelligenceHook(gcp_conn_id="test")
def setUp(self): with mock.patch( "airflow.contrib.hooks.gcp_video_intelligence_hook.CloudVideoIntelligenceHook.__init__", new=mock_base_gcp_hook_default_project_id, ): self.hook = CloudVideoIntelligenceHook(gcp_conn_id="test")