def test_attrs(self): # start with the defaults at = AccessToken() self.assertEqual(at.token, '') self.assertEqual(at.is_active, True) self.assertEqual(at.expires_on, default_expiry()) self.assertEqual(at.created_at, None) self.assertEqual(at.updated_at, None) self.assertEqual(at.created_by, None) # check the timestamps at = at.save() self.assertIsNotNone(at.created_at) self.assertEqual(at.updated_at, at.created_at) # check the timestamps are updated x = at.created_at at = at.save() # created_at is _not_ updated self.assertEqual(at.created_at, x) # but updated_at _is_ self.assertTrue(at.updated_at > at.created_at) self.assertTrue(at.is_valid) self.assertFalse(at.has_expired)
def test_default_expiry(self): self.assertEqual( default_expiry(), now().date() + timedelta(days=PERIMETER_DEFAULT_EXPIRY) )