diff --git a/Dockerfile b/Dockerfile index 98e7ffc..71505ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -98,7 +98,6 @@ ENV TZ=${TZ} \ python3-greenlet \ python3-pip \ python3-tz \ - python3-unicodecsv \ python3-yaml \ ${ADD_DEB_PACKAGES}" diff --git a/pygeoapi/formatter/csv_.py b/pygeoapi/formatter/csv_.py index 664bc88..51a6ded 100644 --- a/pygeoapi/formatter/csv_.py +++ b/pygeoapi/formatter/csv_.py @@ -27,11 +27,10 @@ # # ================================================================= +import csv import io import logging -import unicodecsv as csv - from pygeoapi.formatter.base import BaseFormatter, FormatterSerializationError LOGGER = logging.getLogger(__name__) @@ -83,10 +82,11 @@ class CSVFormatter(BaseFormatter): # TODO: implement wkt geometry serialization LOGGER.debug('not a point geometry, skipping') + print("JJJ", fields) LOGGER.debug(f'CSV fields: {fields}') try: - output = io.BytesIO() + output = io.StringIO() writer = csv.DictWriter(output, fields) writer.writeheader() @@ -101,7 +101,7 @@ class CSVFormatter(BaseFormatter): LOGGER.error(err) raise FormatterSerializationError('Error writing CSV output') - return output.getvalue() + return output.getvalue().encode('utf-8') def __repr__(self): return f' {self.name}' diff --git a/requirements.txt b/requirements.txt index ef0f47d..601f51b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,4 +16,3 @@ requests shapely SQLAlchemy<2.0.0 tinydb -unicodecsv diff --git a/tests/api/test_itemtypes.py b/tests/api/test_itemtypes.py index 283bb0c..2cd4458 100644 --- a/tests/api/test_itemtypes.py +++ b/tests/api/test_itemtypes.py @@ -578,6 +578,13 @@ def test_get_collection_item(config, api_): assert 'prev' not in feature['links'] assert 'next' not in feature['links'] + req = mock_api_request() + rsp_headers, code, response = get_collection_item(api_, req, 'norway_pop', + '790') + feature = json.loads(response) + + assert feature['properties']['name'] == 'Ă…lesund' + def test_get_collection_item_json_ld(config, api_): req = mock_api_request({'f': 'jsonld'})