def parse_comptarget(self, req): """Prase GET fragments that would includes optional arguments such as `gte` and `lte`.""" gte, lte = req.GET.get('gte', None), req.GET.get('lte', None) try: gte = dtutils.parse(gte) if gte else dtutils.ago(days=7) lte = dtutils.parse(lte) if lte else datetime.now() except: gte, lte = None, None return (gte, lte, )
def test_raises_dtutils_parse(): with raises(ValueError): dtutils.parse('1111111111111') dtutils.parse('to be failed')
def test_dtutils_parse(text, expected): assert dtutils.parse(text) == expected