def test_success_get_model(self, mock_hook):
        task = MLEngineGetModelOperator(task_id="task-id",
                                        project_id=TEST_PROJECT_ID,
                                        model_name=TEST_MODEL_NAME,
                                        gcp_conn_id=TEST_GCP_CONN_ID,
                                        delegate_to=TEST_DELEGATE_TO)

        result = task.execute(None)

        mock_hook.assert_called_once_with(delegate_to=TEST_DELEGATE_TO,
                                          gcp_conn_id=TEST_GCP_CONN_ID)
        mock_hook.return_value.get_model.assert_called_once_with(
            project_id=TEST_PROJECT_ID, model_name=TEST_MODEL_NAME)
        self.assertEqual(mock_hook.return_value.get_model.return_value, result)
Esempio n. 2
0
    def test_success_get_model(self, mock_hook):
        task = MLEngineGetModelOperator(
            task_id="task-id",
            project_id=TEST_PROJECT_ID,
            model_name=TEST_MODEL_NAME,
            gcp_conn_id=TEST_GCP_CONN_ID,
            delegate_to=TEST_DELEGATE_TO,
            impersonation_chain=TEST_IMPERSONATION_CHAIN,
        )

        result = task.execute(None)

        mock_hook.assert_called_once_with(
            delegate_to=TEST_DELEGATE_TO,
            gcp_conn_id=TEST_GCP_CONN_ID,
            impersonation_chain=TEST_IMPERSONATION_CHAIN,
        )
        mock_hook.return_value.get_model.assert_called_once_with(
            project_id=TEST_PROJECT_ID, model_name=TEST_MODEL_NAME)
        assert mock_hook.return_value.get_model.return_value == result