示例#1
0
 def _create_two_users_to_deserialize(self):
     user = MyUser(username="******", password="******")
     user2 = MyUser(username="******", password="******")
     user.save()
     user2.save()
     self.mc.serialize_into_store()
     user.username = "******"
     user2.username = "******"
     Store.objects.filter(id=user.id).update(serialized=json.dumps(user.serialize()), dirty_bit=True)
     Store.objects.filter(id=user2.id).update(serialized=json.dumps(user2.serialize()), dirty_bit=True)
     return user, user2
示例#2
0
 def test_regular_model_deserialization(self):
     # deserialization should be able to handle multiple records
     user = MyUser(username='******', password='******')
     user2 = MyUser(username='******', password='******')
     user.save(update_dirty_bit_to=False)
     user2.save(update_dirty_bit_to=False)
     user.username = '******'
     user2.username = '******'
     StoreModelFacilityFactory(id=user.id,
                               serialized=json.dumps(user.serialize()),
                               model_name="user")
     StoreModelFacilityFactory(id=user2.id,
                               serialized=json.dumps(user2.serialize()),
                               model_name="user")
     self.mc.deserialize_from_store()
     self.assertFalse(MyUser.objects.filter(username='******').exists())
     self.assertFalse(MyUser.objects.filter(username='******').exists())
     self.assertTrue(MyUser.objects.filter(username='******').exists())
     self.assertTrue(MyUser.objects.filter(username='******').exists())