def test_update_employment_different_profile(self):
"""
Make sure we can't edit an employment for a different profile
"""
with mute_signals(post_save):
employment1 = EmploymentFactory.create()
employment2 = EmploymentFactory.create()
employment_object = EmploymentSerializer(employment1).data
employment_object['id'] = employment2.id
serializer = ProfileSerializer(instance=employment1.profile, data={
'work_history': [employment_object], 'education': []
})
serializer.is_valid(raise_exception=True)
with self.assertRaises(ValidationError) as ex:
serializer.save()
assert ex.exception.detail == ["Work history {} does not exist".format(employment2.id)]
评论列表
文章目录