Skip to content

Commit

Permalink
[QOLDEV-554] add unit test for time ranges being preserved as strings
Browse files Browse the repository at this point in the history
  • Loading branch information
ThrawnCA committed Aug 22, 2023
1 parent 13d076f commit 03967f7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ckanext/xloader/tests/samples/non_timestamp_sample.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Title,Postal postcode,Latitude,Longitude,Mon am,Mon pm,Last updated
Adavale,4474,-25.9092582,144.5975769,8:00,16:00,19/07/2018
Aramac,4726,-22.971298,145.241481,9:00-13:00,14:00-16:45,17/07/2018
19 changes: 19 additions & 0 deletions ckanext/xloader/tests/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,3 +1215,22 @@ def test_with_mixed_quotes(self, Session):
logger=logger,
)
assert len(self._get_records(Session, resource_id)) == 2

def test_preserving_time_ranges(self, Session):
""" Time ranges should not be treated as timestamps
"""
csv_filepath = get_sample_filepath("non_timestamp_sample.csv")
resource = factories.Resource()
resource_id = resource['id']
loader.load_table(
csv_filepath,
resource_id=resource_id,
mimetype="text/csv",
logger=logger,
)
assert self._get_records(Session, resource_id) == [
(1, "Adavale", 4474, Decimal("-25.9092582"), Decimal("144.5975769"),
"8:00", "16:00", datetime.datetime(2018, 7, 19)),
(2, "Aramac", 4726, Decimal("-22.971298"), Decimal("145.241481"),
"9:00-13:00", "14:00-16:45", datetime.datetime(2018, 7, 17))
]

0 comments on commit 03967f7

Please sign in to comment.