Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working type inference for all but dates/datetimes. #210.
- Loading branch information
Showing
2 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/usr/bin/env python | ||
|
||
try: | ||
import unittest2 as unittest | ||
except ImportError: | ||
import unittest | ||
|
||
from agate.column_types import * | ||
from agate.inference import * | ||
|
||
class TestTypeInference(unittest.TestCase): | ||
def setUp(self): | ||
pass | ||
|
||
def testTextType(self): | ||
rows = [ | ||
('a',), | ||
('b',), | ||
('',) | ||
] | ||
|
||
inferred = infer_types(rows) | ||
|
||
self.assertIsInstance(inferred[0], TextType) | ||
|
||
def testNumberType(self): | ||
rows = [ | ||
('1.7',), | ||
('200000000',), | ||
('',) | ||
] | ||
|
||
inferred = infer_types(rows) | ||
|
||
self.assertIsInstance(inferred[0], NumberType) | ||
|
||
def testBooleanType(self): | ||
rows = [ | ||
('True',), | ||
('FALSE',), | ||
('',) | ||
] | ||
|
||
inferred = infer_types(rows) | ||
|
||
self.assertIsInstance(inferred[0], BooleanType) | ||
|
||
def testDateType(self): | ||
rows = [ | ||
('5/7/84',), | ||
('2/28/1997',), | ||
('',) | ||
] | ||
|
||
inferred = infer_types(rows) | ||
|
||
self.assertIsInstance(inferred[0], DateType) | ||
|
||
def testDateTimeType(self): | ||
rows = [ | ||
('5/7/84 3:44:12',), | ||
('2/28/1997 3:12 AM',), | ||
('',) | ||
] | ||
|
||
inferred = infer_types(rows) | ||
|
||
self.assertIsInstance(inferred[0], DateTimeType) | ||
|
||
def testTimeDeltaType(self): | ||
rows = [ | ||
('1:42',), | ||
('1w 27h',), | ||
('',) | ||
] | ||
|
||
inferred = infer_types(rows) | ||
|
||
self.assertIsInstance(inferred[0], TimeDeltaType) |