def test_execute_no_client(*args): # no keystone authtoken present in configuration dco = DeploymentConfigurationOperator(main_dag_name="main", shipyard_conf="shipyard.conf", task_id="t1") with pytest.raises(AirflowException) as expected_exc: dco.execute(context={}) assert ("Failed to retrieve deployment configuration yaml" ) in str(expected_exc)
def test_execute_exception(): """Test that execute results in a failure with bad context""" dco = DeploymentConfigurationOperator(main_dag_name="main", shipyard_conf="shipyard.conf", task_id="t1") with pytest.raises(AirflowException) as expected_exc: # Design revision is not set on xcom pull dco.execute(context={}) assert ("Design_revision is not set. Cannot proceed with retrieval" " of the design configuration") in str(expected_exc)
def test_execute_no_client(get_revision_id, read_config): # no keystone authtoken present in configuration dco = DeploymentConfigurationOperator(main_dag_name="main", shipyard_conf="shipyard.conf", task_id="t1") dco.config = make_fake_config() with pytest.raises(AirflowException) as expected_exc: dco.execute(context={'task_instance': 'asdf'}) assert ("Failed to retrieve deployment-configuration yaml") in str( expected_exc) get_revision_id.assert_called_once_with('asdf') read_config.assert_called_once_with()