Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dfda2ba
commit 416c67a
Showing
10 changed files
with
185 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[report] | ||
exclude_lines = | ||
# Have to re-enable the standard pragma | ||
pragma: no cover | ||
|
||
# Don't complain if tests don't hit defensive assertion code: | ||
raise NotImplementedError |
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
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,6 @@ | ||
[nosetests] | ||
match=^test | ||
nocapture=1 | ||
with-coverage=1 | ||
cover-package=gsheetsdb | ||
cover-erase=1 |
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 |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
] | ||
|
||
development_extras = [ | ||
'coverage', | ||
'nose', | ||
'pipreqs', | ||
'twine', | ||
|
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,101 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from collections import namedtuple | ||
import datetime | ||
import unittest | ||
|
||
from .context import convert_rows | ||
|
||
|
||
|
||
class ConvertTestSuite(unittest.TestCase): | ||
|
||
payload = { | ||
"version": "0.6", | ||
"reqId": "0", | ||
"status": "ok", | ||
"sig": "1788543417", | ||
"table": { | ||
"cols": [ | ||
{ | ||
"id": "A", | ||
"label": "datetime", | ||
"type": "datetime", | ||
"pattern": "M/d/yyyy H:mm:ss", | ||
}, | ||
{ | ||
"id": "B", | ||
"label": "number", | ||
"type": "number", | ||
"pattern": "General", | ||
}, | ||
{ | ||
"id": "C", | ||
"label": "boolean", | ||
"type": "boolean", | ||
}, | ||
{ | ||
"id": "D", | ||
"label": "date", | ||
"type": "date", | ||
"pattern": "M/d/yyyy", | ||
},{ | ||
"id": "E", | ||
"label": "timeofday", | ||
"type": "timeofday", | ||
"pattern": "h:mm:ss am/pm", | ||
},{ | ||
"id": "F", | ||
"label": "string", | ||
"type": "string", | ||
}, | ||
], | ||
"rows": [ | ||
{ | ||
"c": [ | ||
{"v": "Date(2018,8,1,0,0,0)", "f": "9/1/2018 0:00:00"}, | ||
{"v": 1.0, "f": "1"}, | ||
{"v": True, "f": "TRUE"}, | ||
{"v": "Date(2018,0,1)", "f": "1/1/2018"}, | ||
{"v": [17,0,0,0], "f": "5:00:00 PM"}, | ||
{"v": "test"}, | ||
], | ||
}, | ||
{ | ||
"c": [ | ||
None, | ||
{"v": 1.0, "f": "1"}, | ||
{"v": True, "f": "TRUE"}, | ||
None, | ||
None, | ||
{"v": "test"}, | ||
], | ||
}, | ||
], | ||
}, | ||
} | ||
|
||
def test_convert(self): | ||
cols = self.payload['table']['cols'] | ||
rows = self.payload['table']['rows'] | ||
result = convert_rows(cols, rows) | ||
Row = namedtuple('Row', 'datetime number boolean date timeofday string') | ||
expected = [ | ||
Row( | ||
datetime=datetime.datetime(2018, 9, 1, 0, 0), | ||
number=1.0, | ||
boolean=True, | ||
date=datetime.date(2018, 1, 1), | ||
timeofday=datetime.time(17, 0), | ||
string='test', | ||
), | ||
Row( | ||
datetime=None, | ||
number=1.0, | ||
boolean=True, | ||
date=None, | ||
timeofday=None, | ||
string='test', | ||
), | ||
] | ||
self.assertEquals(result, expected) |
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