Skip to content

Commit

Permalink
fix: reorganize tests for object type
Browse files Browse the repository at this point in the history
  • Loading branch information
TyShkan committed Mar 30, 2023
1 parent b211452 commit 58aecbd
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tap_spreadsheets_anywhere/test/test_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_convert(self):
# strings
self.assertEqual(convert('4 o clock'), ('4 o clock', 'string'))

# objects
def test_convert_objects(self):
self.assertEqual(convert("{'k': 'v','k': 'v'}"), ("{'k': 'v','k': 'v'}", 'string'))
self.assertEqual(convert({'k': 'v','k': 'v'}), ({'k': 'v','k': 'v'}, 'object'))
self.assertEqual(convert({'k': 'v','k': 'v'}, 'object'), ({'k': 'v','k': 'v'}, 'object'))
Expand All @@ -59,7 +59,6 @@ def test_pick_datatype(self):
self.assertEqual(pick_datatype({'string': 1}), 'string')
self.assertEqual(pick_datatype({'integer': 1}), 'integer')
self.assertEqual(pick_datatype({'number': 1}), 'number')
self.assertEqual(pick_datatype({'object': 1}), 'object')

self.assertEqual(pick_datatype({'number': 1,
'integer': 1}), 'number')
Expand All @@ -68,10 +67,13 @@ def test_pick_datatype(self):
'integer': 1}), 'string')
self.assertEqual(pick_datatype({'string': 1,
'number': 1}), 'string')
self.assertEqual(pick_datatype({'string': 1,
'object': 1}), 'string')
self.assertEqual(pick_datatype({}), 'string')

def test_pick_datatype_objects(self):
self.assertEqual(pick_datatype({'object': 1}), 'object')
self.assertEqual(pick_datatype({'string': 1,
'object': 1}), 'string')

def test_generate_schema(self):
self.assertEqual(
generate_schema([{'id': '1', 'first_name': 'Connor'},
Expand All @@ -97,6 +99,7 @@ def test_generate_schema(self):
{'id': {'type': ['null', 'integer'],},
'date': {'type': ['null', 'string'],}})

def test_generate_schema_objects(self):
self.assertEqual(
generate_schema([{'id': '1', 'obj': { 'date': '2017-01-01', 'count': 100 }},
{'id': '2', 'obj': { 'date': '2017-01-01', 'count': 0 }}]),
Expand Down

0 comments on commit 58aecbd

Please sign in to comment.