-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attempt to guess the Airtable type for Fields (#6)
- Loading branch information
Showing
2 changed files
with
70 additions
and
9 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,26 @@ | ||
from shillelagh.fields import Boolean, Float, String | ||
|
||
from airtabledb import fields | ||
from airtabledb.adapter import guess_field | ||
|
||
|
||
def test_guess_field(): | ||
assert type(guess_field([1])) is Float | ||
assert type(guess_field([1.5])) is Float | ||
assert type(guess_field([1, 1.5])) is Float | ||
|
||
assert type(guess_field([True])) is Boolean | ||
|
||
assert type(guess_field(["a"])) is String | ||
|
||
assert type(guess_field([1, {"specialValue": "NaN"}])) is fields.MaybeListString | ||
assert type(guess_field([1.5, {"specialValue": "NaN"}])) is fields.MaybeListString | ||
assert ( | ||
type(guess_field([1.5, 1, {"specialValue": "NaN"}])) is fields.MaybeListString | ||
) | ||
|
||
# Not sure if this comes up in practice | ||
assert type(guess_field([["a"], ["b"]])) is fields.MaybeListString | ||
|
||
# Not sure if this comes up in practice | ||
assert type(guess_field(["a", 4])) is fields.MaybeListString |