'Test dtparse with relative dates'

def testDtParseRelative(self):

    assertTrue = self.assertTrue
    assertRaises = self.assertRaises
    assertEqual = self.assertEqual
    ts = S3TimeSeries
    start = datetime.datetime(2014, 1, 3, 11, 30)
    result = ts.dtparse('+1    year', start=start)
    assertTrue(isinstance(result, datetime.datetime))
    assertEqual(result, datetime.datetime(2015, 1, 3, 11, 30, 0))
    result = ts.dtparse('-3    days', start=start)
    assertTrue(isinstance(result, datetime.datetime))
    assertEqual(result, datetime.datetime(2013, 12, 31, 11, 30, 0))
    result = ts.dtparse('+5    hours', start=start)
    assertTrue(isinstance(result, datetime.datetime))
    assertEqual(result, datetime.datetime(2014, 1, 3, 16, 30, 0))
    result = ts.dtparse('-6    months', start=start)
    assertTrue(isinstance(result, datetime.datetime))
    assertEqual(result, datetime.datetime(2013, 7, 3, 11, 30, 0))
    result = ts.dtparse('+12    weeks', start=start)
    assertTrue(isinstance(result, datetime.datetime))
    assertEqual(result, datetime.datetime(2014, 3, 28, 11, 30, 0))
    result = ts.dtparse('', start=start)
    assertTrue(isinstance(result, datetime.datetime))
    assertEqual(result.year, start.year)
    assertEqual(result.month, start.month)
    assertEqual(result.day, start.day)
    assertEqual(result.hour, start.hour)
    assertEqual(result.minute, start.minute)
    result = ts.dtparse(None, start=start)
    assertTrue(isinstance(result, datetime.datetime))
    assertEqual(result.year, start.year)
    assertEqual(result.month, start.month)
    assertEqual(result.day, start.day)
    assertEqual(result.hour, start.hour)
    assertEqual(result.minute, start.minute)
    assertRaises(ValueError, ts.dtparse, 'invalid')
