Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Commit

Permalink
Use correct solr date format
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Graves committed Jul 28, 2016
1 parent f180de3 commit 42fb222
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion kepler/tasks.py
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion tests/test_tasks.py
Expand Up @@ -4,14 +4,16 @@
import os.path
import re

import arrow
import pytest
import requests_mock
from mock import patch, DEFAULT

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')
Expand Down Expand Up @@ -281,3 +283,9 @@ def testFgdcToModsReturnsMods(bag_tif):
fgdc = os.path.join(bag_tif, 'data/fgdc.xml')
mods = _fgdc_to_mods(fgdc)
assert u'<mods:title>Some land</mods:title>' 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'

0 comments on commit 42fb222

Please sign in to comment.