def test_filled_out_serializer(self):
"""
Get a user's own profile, ensure that we used ProfileFilledOutSerializer
"""
with mute_signals(post_save):
profile = ProfileFactory.create(user=self.user1, filled_out=True)
self.client.force_login(self.user1)
patch_data = ProfileSerializer(profile).data
# PATCH may not succeed, we just care that the right serializer was used
with patch(
'profiles.views.ProfileFilledOutSerializer.__new__',
autospec=True,
side_effect=ProfileFilledOutSerializer.__new__
) as mocked:
self.client.patch(self.url1, content_type="application/json", data=json.dumps(patch_data))
assert mocked.called
评论列表
文章目录