def test_get_doc_mock_deckhand(*args): """Get doc should return a document""" dco = DeploymentConfigurationOperator(main_dag_name="main", shipyard_conf="shipyard.conf", task_id="t1") dco.config = make_fake_config() doc = dco.get_doc(99) assert doc == 'abcdefg'
def test_get_doc_no_deckhand(): """Get doc should fail to contact deckhand return a document""" 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.get_doc(99) assert "Failed to retrieve deployment" in str(expected_exc)
def test_get_doc_mock_deckhand_invalid(*args): """Get doc should return a document""" dco = DeploymentConfigurationOperator(main_dag_name="main", shipyard_conf="shipyard.conf", task_id="t1") dco.config = make_fake_config() with pytest.raises(AirflowException) as airflow_ex: dco.get_doc(99) assert 'valid deployment-configuration' in str(airflow_ex)
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()