如何在数据更新时创建测试脚本

2024-09-25 10:34:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在创建一个测试脚本,以确保数据被修改

def test_mission_if_collabor_and_user_are_the_same(self):
        """ If the user is also written as the collaborator,
        Mission should not duplicate"""

        #Check length of missions return 2
        actuser = ActuserViewModel(self.user_name[0], 'M')
        actuser.get_mission_list(self.user_name[0])

        #Check if it shows the mission list
        self.assertEqual(len(actuser.missionList), 2)

        #update one of the missions where collaborator is the same as the user

        # Call view by POST method

        mission = MissionViewModel(self.mission_id_list[0])
        missionForm = MissionForm(data={'name': 'test name','collaborator':'useraaaa'}, instance=mission.db)
        mission.save_to_actinbox()

        #save updated test

        missionCheck = MissionViewModel(self.mission_id_list[0])
        self.assertEqual(missionCheck.db.collaborator, 2)

我对这部分编码没有信心,systax可能不正确,因为它没有显示数据已经更新

missionForm = MissionForm(data={'name': 'test name','collaborator':'useraaaa'}, instance=mission.db)

Tags: the数据nametestselfdbifis