Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
92 lines (72 sloc) 2.55 KB
import sys
if sys.version_info < (2, 7):
import unittest2 as unittest
import unittest
from datetime import datetime
from datetime import date
from import parse_date
from import transform_params
from import convert_keys
from import convert_case
from import convert_boolean
from import normalize_dates
class CoreTest(unittest.TestCase):
def test_date(self):
d = date(2009,10,10)
self.assertEquals(parse_date(d), "2009-10-10")
def test_datetime(self):
d = datetime(2009,10,10)
self.assertEquals(parse_date(d), "2009-10-10")
def test_string_date(self):
d = "2009-10-10"
self.assertEquals(parse_date(d), "2009-10-10")
def test_string_date(self):
d = None
self.assertEquals(parse_date(d), None)
def test_string_date(self):
d = False
self.assertEquals(parse_date(d), None)
def test_fparam(self):
d = {"HEY": None, "YOU": 3}
ed = {"YOU":3}
self.assertEquals(transform_params(d), ed)
def test_fparam_booleans(self):
d = {"HEY": None, "YOU": 3, "Activated": False}
ed = {"YOU":3, "Activated": "false"}
self.assertEquals(transform_params(d), ed)
def test_normalize_dates(self):
def foo(on=None, before=None, after=None):
return {
"on": on,
"before": before,
"after": after,
d = foo(on="2009-10-10", before=date(2009,10,10),
self.assertEquals(d["on"], "2009-10-10")
self.assertEquals(d["after"], "2009-10-10")
self.assertEquals(d["before"], "2009-10-10")
def test_convert_case(self):
self.assertEquals(convert_case("from_"), "From")
self.assertEquals(convert_case("to"), "To")
self.assertEquals(convert_case("friendly_name"), "FriendlyName")
def test_convert_bool(self):
self.assertEquals(convert_boolean(False), "false")
self.assertEquals(convert_boolean(True), "true")
self.assertEquals(convert_boolean(1), 1)
def test_convert_keys(self):
d = {
"from_": 0,
"to": 0,
"friendly_name": 0,
"ended": 0,
ed = {
"From": 0,
"To": 0,
"FriendlyName": 0,
"EndTime": 0,
self.assertEquals(ed, convert_keys(d))
Jump to Line
Something went wrong with that request. Please try again.