def test_to_model(self): ''' the big boy of this module. it feels janky to test this with actual models rather than a test model, but I don't know how to make a test model so here we are. ''' instance = ActivityObject(id='a', type='b') with self.assertRaises(ActivitySerializerError): instance.to_model(models.User) # test setting simple fields self.assertEqual(self.user.name, '') update_data = activitypub.Person(**self.user.to_activity()) update_data.name = 'New Name' update_data.to_model(models.User, self.user) self.assertEqual(self.user.name, 'New Name')
def test_to_model_invalid_model(self, _): """catch mismatch between activity type and model type""" instance = ActivityObject(id="a", type="b") with self.assertRaises(ActivitySerializerError): instance.to_model(model=models.User)
def test_to_model_invalid_model(self): ''' catch mismatch between activity type and model type ''' instance = ActivityObject(id='a', type='b') with self.assertRaises(ActivitySerializerError): instance.to_model(models.User)