예제 #1
0
    def test_delete_cases(self):
        self.client.login(username=self.plan_tester.username,
                          password='******')

        post_data = {'case': [self.case_1.pk, self.case_3.pk]}
        response = self.client.post(self.cases_url, post_data)
        data = json_loads(response.content)

        self.assertEqual(0, data['rc'])
        self.assertEqual('ok', data['response'])
        self.assertFalse(self.plan.case.filter(
            pk__in=[self.case_1.pk, self.case_3.pk]).exists())

        # Assert action logs are recorded for plan and case correctly

        expected_log = 'Remove from plan {}'.format(self.plan.pk)
        for pk in (self.case_1.pk, self.case_3.pk):
            log = TCMSLogModel.get_logs_for_model(TestCase, pk)[0]
            self.assertEqual(expected_log, log.new_value)

        for plan_pk, case_pk in ((self.plan.pk, self.case_1.pk),
                                 (self.plan.pk, self.case_3.pk)):
            expected_log = 'Remove case {} from plan {}'.format(
                case_pk, plan_pk)
            self.assertTrue(
                TCMSLogModel.objects.filter(new_value=expected_log).exists())
예제 #2
0
파일: tests.py 프로젝트: xbln/Kiwi
    def test_delete_cases(self):
        self.client.login(username=self.plan_tester.username,
                          password='******')

        post_data = {'case': [self.case_1.pk, self.case_3.pk]}
        response = self.client.post(self.cases_url, post_data)
        data = json.loads(
            str(response.content, encoding=settings.DEFAULT_CHARSET))

        self.assertEqual(0, data['rc'])
        self.assertEqual('ok', data['response'])
        self.assertFalse(
            self.plan.case.filter(
                pk__in=[self.case_1.pk, self.case_3.pk]).exists())

        # Assert action logs are recorded for plan and case correctly

        expected_log = 'Remove from plan {}'.format(self.plan.pk)
        for pk in (self.case_1.pk, self.case_3.pk):
            log = TCMSLogModel.get_logs_for_model(TestCase, pk)[0]
            self.assertEqual(expected_log, log.action)

        for plan_pk, case_pk in ((self.plan.pk, self.case_1.pk),
                                 (self.plan.pk, self.case_3.pk)):
            expected_log = 'Remove case {} from plan {}'.format(
                case_pk, plan_pk)
            self.assertTrue(
                TCMSLogModel.objects.filter(action=expected_log).exists())
예제 #3
0
파일: __init__.py 프로젝트: cxignited/Kiwi
 def log_action(self, who, action):
     TCMSLogModel(content_object=self,
                  who=who,
                  action=action,
                  site_id=settings.SITE_ID).save()