예제 #1
0
 def test_save(self):
     model = ModelMock('123', self.name, self.expires_in)
     self.assertIsNotExpires(model)
     self.assertEqual(model.expires_in, model.expires_in)
     self.assertEqual(model.key, 'ModelMock_123')
     self.assertEqual(model.value['name'], 'name')
     self.assertGreater(model.value['expired_at'], time.time())
     self.assertCache(model)
예제 #2
0
 def test_value_error(self):
     model = ModelMock(self.uid, None, self.expires_in)
     self.assertRaises(ValueError, lambda: model.save())
예제 #3
0
 def test_key_error(self):
     model = ModelMock(None, self.name, self.expires_in)
     self.assertRaises(KeyError, lambda: model.save())
예제 #4
0
 def test_none_expires_in(self):
     model = ModelMock(self.uid, self.name, expires_in=None)
     self.assertIsExpires(model)
     self.assertNotCache(model)
예제 #5
0
 def test_is_expires(self):
     model = ModelMock(self.uid, self.name, expires_in=-1)
     self.assertIsExpires(model)
     self.assertNotCache(model)
예제 #6
0
 def test_load_cache(self):
     ModelMock(self.uid, self.name, self.expires_in).save()
     model = ModelMock(self.uid, self.name)
     model.load_cache()
     self.assertIsNotExpires(model)
예제 #7
0
 def test_delete(self):
     model = ModelMock('123', self.name, self.expires_in)
     model.save()
     model.delete()
     self.assertIsExpires(model)
     self.assertIsExpires(ModelMock('123', self.name))