diff --git a/kepler/tasks.py b/kepler/tasks.py index 19caa60..56b7623 100644 --- a/kepler/tasks.py +++ b/kepler/tasks.py @@ -285,7 +285,7 @@ def _prep_solr_record(record): record[k] = list(v) else: try: - record[k] = v.isoformat() + record[k] = v.to('utc').format('YYYY-MM-DDTHH:mm:ss') + 'Z' except AttributeError: pass return record diff --git a/tests/test_tasks.py b/tests/test_tasks.py index a8b4cc8..0542d92 100644 --- a/tests/test_tasks.py +++ b/tests/test_tasks.py @@ -4,6 +4,7 @@ import os.path import re +import arrow import pytest import requests_mock from mock import patch, DEFAULT @@ -11,7 +12,8 @@ from kepler.models import Job, Item from kepler.tasks import * from kepler.tasks import (_index_records, _load_marc_records, - _upload_to_geoserver, _fgdc_to_mods) + _prep_solr_record, _upload_to_geoserver, + _fgdc_to_mods) pytestmark = pytest.mark.usefixtures('app') @@ -281,3 +283,9 @@ def testFgdcToModsReturnsMods(bag_tif): fgdc = os.path.join(bag_tif, 'data/fgdc.xml') mods = _fgdc_to_mods(fgdc) assert u'Some land' in mods + + +def test_prep_solr_record_converts_dates(): + now = arrow.now() + rec = _prep_solr_record({'foo': now}) + assert rec['foo'] == now.to('utc').format('YYYY-MM-DDTHH:mm:ss') + 'Z'