def test_has_expired(self): at = AccessToken() at.expires_on = YESTERDAY self.assertTrue(at.has_expired) at.expires_on = TODAY self.assertFalse(at.has_expired) at.expires_on = TOMORROW self.assertFalse(at.has_expired)
def test_str(self): # test unicode, str today = date.today() yesterday = today - timedelta(days=1) at = AccessToken(token="foobar", expires_on=today, is_active=True) self.assertEqual( unicode(at), u"foobar - valid until %s" % today ) at.is_active = False self.assertEqual( unicode(at), u"foobar - inactive" ) at.is_active = True at.expires_on = yesterday self.assertEqual( unicode(at), u"foobar - expired on %s" % yesterday )