Exemple #1
0
 def test_database_create_with_pre_existing_db(self, mock_hook):
     mock_hook.return_value.get_database.return_value = {"name": DB_ID}
     op = SpannerDeployDatabaseInstanceOperator(
         project_id=PROJECT_ID,
         instance_id=INSTANCE_ID,
         database_id=DB_ID,
         ddl_statements=DDL_STATEMENTS,
         task_id="id")
     result = op.execute(None)
     mock_hook.assert_called_once_with(gcp_conn_id="google_cloud_default")
     mock_hook.return_value.create_database.assert_not_called()
     mock_hook.return_value.update_database.assert_not_called()
     self.assertTrue(result)
Exemple #2
0
 def test_database_create_missing_project_id(self, mock_hook):
     mock_hook.return_value.get_database.return_value = None
     op = SpannerDeployDatabaseInstanceOperator(
         instance_id=INSTANCE_ID,
         database_id=DB_ID,
         ddl_statements=DDL_STATEMENTS,
         task_id="id")
     result = op.execute(None)
     mock_hook.assert_called_once_with(
         gcp_conn_id="google_cloud_default",
         impersonation_chain=None,
     )
     mock_hook.return_value.create_database.assert_called_once_with(
         project_id=None,
         instance_id=INSTANCE_ID,
         database_id=DB_ID,
         ddl_statements=DDL_STATEMENTS)
     mock_hook.return_value.update_database.assert_not_called()
     assert result