Skip to content

Commit

Permalink
Merge pull request #217 from JVickery-TBS/fix/type-guessing-numeric
Browse files Browse the repository at this point in the history
Add Mixed Integers Type Guessing to NUMERIC Tests
  • Loading branch information
duttonw authored May 15, 2024
2 parents 92f7cca + 112aff4 commit dd475e7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
10 changes: 7 additions & 3 deletions ckanext/xloader/tests/samples/mixed_numeric_string_sample.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Funding agency,Program title,Maximum (indicative) grant amount
DTIS,Accessible Tourism Infrastructure Grants,Five hundred thousand dollars
DTIS,Boosting Accessible Tourism Experiences Grants,5000
Funding agency,Program title,Maximum (indicative) grant amount,Some mixed integers
DTIS,Accessible Tourism Infrastructure Grants,Five hundred thousand dollars,1
DTIS,Boosting Accessible Tourism Experiences Grants,5000,-1
DTIS,Some Other Grants,5 hundred thousand,0
DTIS,Some Other Grants,$5000,6
DTIS,Some Other Grants,$5 hundred thousand,
DTIS,Some Other Grants,"$5,000.00","5"
23 changes: 22 additions & 1 deletion ckanext/xloader/tests/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ def test_with_mixed_types(self, Session):
mimetype="text/csv",
logger=logger,
)
assert len(self._get_records(Session, resource_id)) == 2
assert len(self._get_records(Session, resource_id)) == 6

def test_reload(self, Session):
csv_filepath = get_sample_filepath("simple.csv")
Expand Down Expand Up @@ -979,6 +979,27 @@ def test_simple_large_file(self, Session):
u"text",
]

def test_with_mixed_types(self, Session):
csv_filepath = get_sample_filepath("mixed_numeric_string_sample.csv")
resource = factories.Resource()
resource_id = resource['id']
loader.load_table(
csv_filepath,
resource_id=resource_id,
mimetype="text/csv",
logger=logger,
)
assert len(self._get_records(Session, resource_id)) == 6

assert self._get_column_types(Session, resource_id) == [
u'int4',
u'tsvector',
u'text',
u'text',
u'text',
u'numeric'
]

# test disabled by default to avoid adding large file to repo and slow test
@pytest.mark.skip
def test_boston_311_complete(self):
Expand Down

0 comments on commit dd475e7

Please sign in to comment.