Beispiel #1
0
 def test_start_should_throw_ex_when_missing_project_id(self, mock_hook):
     with self.assertRaises(AirflowException) as cm:
         op = GceInstanceStartOperator(project_id="",
                                       zone=GCE_ZONE,
                                       resource_id=RESOURCE_ID,
                                       task_id='id')
         op.execute(None)
     err = cm.exception
     self.assertIn("The required parameter 'project_id' is missing",
                   str(err))
     mock_hook.assert_not_called()
Beispiel #2
0
 def test_instance_start(self, mock_hook):
     mock_hook.return_value.start_instance.return_value = True
     op = GceInstanceStartOperator(project_id=GCP_PROJECT_ID,
                                   zone=GCE_ZONE,
                                   resource_id=RESOURCE_ID,
                                   task_id='id')
     result = op.execute(None)
     mock_hook.assert_called_once_with(api_version='v1',
                                       gcp_conn_id='google_cloud_default')
     mock_hook.return_value.start_instance.assert_called_once_with(
         zone=GCE_ZONE, resource_id=RESOURCE_ID, project_id=GCP_PROJECT_ID)
     self.assertTrue(result)
Beispiel #3
0
 def test_start_should_not_throw_ex_when_project_id_none(self, _):
     op = GceInstanceStartOperator(zone=GCE_ZONE,
                                   resource_id=RESOURCE_ID,
                                   task_id='id')
     op.execute(None)