def test_delete_employment(self):
"""
Test that we delete employments which aren't specified in the PATCH
"""
with mute_signals(post_save):
employment1 = EmploymentFactory.create()
EmploymentFactory.create(profile=employment1.profile)
# has a different profile
employment3 = EmploymentFactory.create()
assert employment1.profile.work_history.count() == 2
employment_object1 = EmploymentSerializer(employment1).data
serializer = ProfileSerializer(instance=employment1.profile, data={
'work_history': [employment_object1], 'education': []
})
serializer.is_valid(raise_exception=True)
serializer.save()
assert employment1.profile.work_history.count() == 1
assert employment1.profile.work_history.first() == employment1
# Other profile is unaffected
assert employment3.profile.work_history.count() == 1
评论列表
文章目录