def test_get_project_from_s3_not_found(self, mock_get_conn): mock_bucket = mock_get_conn.return_value.get_bucket.return_value mock_bucket.get_key.return_value = None url = normalize_url('s3://bucket/path/to/key/compose_addons.yml') with pytest.raises(FetchExternalConfigError) as exc_context: get_project_from_s3(url) expected = "Failed to include %s: Not Found" % url.geturl() assert expected in str(exc_context.exconly())
def test_get_project_from_s3_bucket_error(self, mock_get_conn): mock_get_bucket = mock_get_conn.return_value.get_bucket mock_get_bucket.side_effect = boto.exception.S3ResponseError( 404, "Bucket Not Found") url = normalize_url('s3://bucket/path/to/key/fig.yml') with pytest.raises(FetchExternalConfigError) as exc_context: get_project_from_s3(url) expected = ("Failed to include %s: " "S3ResponseError: 404 Bucket Not Found" % url.geturl()) assert expected in str(exc_context.exconly())
def test_get_project_from_s3_bucket_error(self, mock_get_conn): mock_get_bucket = mock_get_conn.return_value.get_bucket mock_get_bucket.side_effect = boto.exception.S3ResponseError( 404, "Bucket Not Found") url = normalize_url('s3://bucket/path/to/key/fig.yml') with pytest.raises(FetchExternalConfigError) as exc_context: get_project_from_s3(url) expected = ( "Failed to include %s: " "S3ResponseError: 404 Bucket Not Found" % url.geturl()) assert expected in str(exc_context.exconly())
def test_get_project_from_s3(self, mock_get_conn): mock_bucket = mock_get_conn.return_value.get_bucket.return_value mock_key = mock_bucket.get_key.return_value mock_key.get_contents_as_string.return_value = 'foo:\n build: .' url = normalize_url('s3://bucket/path/to/key/compose_addons.yml') project = get_project_from_s3(url) assert project == {'foo': {'build': '.'}} mock_get_conn.assert_called_once_with() mock_get_conn.return_value.get_bucket.assert_called_once_with('bucket') mock_bucket.get_key.assert_called_once_with( '/path/to/key/compose_addons.yml')