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

Commit

Permalink
EVL XLS hyphens and blank spaces in numeric fields
Browse files Browse the repository at this point in the history
The EVL spreadsheet contains some blank cells and hyphens. If we store these
as strings we can't do maths on them. They should be zeros.

Makes the test data closer to the real data.
  • Loading branch information
alexmuller committed Aug 30, 2013
1 parent 678a5fd commit fce7bb4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions backdrop/contrib/evl_volumetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def create_transaction_data(header, row):

def transaction_data(date_volume):
date, volume = date_volume
if volume == "" or volume == "-":
volume = 0
date = as_utc(datetime.strptime(date, "%b %Y"))
service = SERVICES[row[SERVICE_INDEX]]
channel = row[CHANNEL_INDEX].lower().replace(" ", "-")
Expand Down
6 changes: 6 additions & 0 deletions features/contrib/evl_upload.feature
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,9 @@ Feature: EVL Upload
and I enter "evl-volumetrics.xls" into the file upload field
and I click "Upload"
then the platform should have "336" items stored in "evl_volumetrics"
and the "evl_volumetrics" bucket should have items:
"""
{"_timestamp": "2012-04-01T00:00:00+00:00", "transaction": "V-V890 SORN Declaration Refunds Input", "service": "sorn", "volume": 1025.0}
{"_timestamp": "2012-05-01T00:00:00+00:00", "transaction": "V-V890 SORN Declaration Vehicles Input", "service": "sorn", "volume": 0.0}
{"_timestamp": "2012-06-01T00:00:00+00:00", "transaction": "V-V890 SORN Declaration Vehicles Triage", "service": "sorn", "volume": 0.0}
"""
Binary file modified features/fixtures/contrib/evl-volumetrics.xls
Binary file not shown.
6 changes: 4 additions & 2 deletions tests/contrib/test_evl_upload_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def test_volumetrics_raw_data_to_normalised_data(self):
["", "", "V-V890 SORN Declaration", 1023, 2023, 3023],
["", "", "V-V890 SORN Declaration Key from Image", 1024, 2024, 3024],
["", "", "V-V890 SORN Declaration Refunds Input", 1025, 2025, 3025],
["", "", "V-V890 SORN Declaration Vehicles Input", 1026, 2026, 3026],
["", "", "V-V890 SORN Declaration Vehicles Triage", 1027, 2027, 3027],
["", "", "V-V890 SORN Declaration Vehicles Input", "-", 2026, 3026],
["", "", "V-V890 SORN Declaration Vehicles Triage", "", 2027, 3027],
["_", "_", "_", "_", "_", "_"],
["_", "_", "_", "_", "_", "_"],
["_", "_", "_", "_", "_", "_"],
Expand All @@ -160,3 +160,5 @@ def test_volumetrics_raw_data_to_normalised_data(self):
assert_that(header, is_(["_timestamp", "service", "channel", "transaction", "volume"]))
assert_that(rows[0], is_(["2012-04-01T00:00:00+00:00", "tax-disc", "assisted-digital", "V-V10 Licence Application Post Office", 1000]))
assert_that(rows[-1], is_(["2013-03-01T00:00:00+00:00", "sorn", "manual", "V-V890 SORN Declaration Vehicles Triage", 3027]))
assert_that(rows[-2], is_(["2012-04-01T00:00:00+00:00", "sorn", "manual", "V-V890 SORN Declaration Vehicles Triage", 0]))
assert_that(rows[-4], is_(["2012-04-01T00:00:00+00:00", "sorn", "manual", "V-V890 SORN Declaration Vehicles Input", 0]))

0 comments on commit fce7bb4

Please sign in to comment.