Exemplo n.º 1
0
    def test_nonexistent_object(self):
        case_data = sample_case_data.copy()
        case_data['author'] = '*****@*****.**'
        xmldict = self._create_xml_dict(case_data)
        self.assertRaises(User.DoesNotExist, process_case, xmldict['testcase'])

        case_data = sample_case_data.copy()
        case_data['defaulttester'] = '*****@*****.**'
        xmldict = self._create_xml_dict(case_data)
        self.assertRaises(User.DoesNotExist, process_case, xmldict['testcase'])

        case_data = sample_case_data.copy()
        case_data['priority'] = 'PP'
        xmldict = self._create_xml_dict(case_data)
        self.assertRaises(Priority.DoesNotExist,
                          process_case, xmldict['testcase'])

        case_data = sample_case_data.copy()
        case_data['priority'] = ''
        xmldict = self._create_xml_dict(case_data)
        self.assertRaises(ValueError, process_case, xmldict['testcase'])

        case_data = sample_case_data.copy()
        case_data['status'] = 'UNKNOWN_STATUS'
        xmldict = self._create_xml_dict(case_data)
        self.assertRaises(TestCaseStatus.DoesNotExist,
                          process_case, xmldict['testcase'])

        case_data = sample_case_data.copy()
        case_data['status'] = ''
        xmldict = self._create_xml_dict(case_data)
        self.assertRaises(ValueError, process_case, xmldict['testcase'])

        case_data = sample_case_data.copy()
        case_data['automated'] = ''
        xmldict = self._create_xml_dict(case_data)
        cleaned_case = process_case(xmldict['testcase'])
        self.assertEqual(False, cleaned_case['is_automated'])

        case_data = sample_case_data.copy()
        case_data['tag'] = ''
        xmldict = self._create_xml_dict(case_data)
        cleaned_case = process_case(xmldict['testcase'])
        self.assertEqual(None, cleaned_case['tags'])

        case_data = sample_case_data.copy()
        case_data['categoryname'] = ''
        xmldict = self._create_xml_dict(case_data)
        self.assertRaises(ValueError, process_case, xmldict['testcase'])
Exemplo n.º 2
0
    def test_process_case(self):
        xmldict = self._create_xml_dict(sample_case_data)

        cleaned_case = process_case(xmldict['testcase'])
        self.assertEqual(self.user.id, cleaned_case['author_id'])
        self.assertEqual(self.user, cleaned_case['author'])
        self.assertEqual(sample_case_data['summary'], cleaned_case['summary'])
        self.assertEqual(None, cleaned_case['default_tester_id'])
        p1 = Priority.objects.get(value=sample_case_data['priority'])
        self.assertEqual(p1.pk, cleaned_case['priority_id'])
        self.assertEqual(False, cleaned_case['is_automated'])
        self.assertEqual(sample_case_data['categoryname'],
                         cleaned_case['category_name'])
        self.assert_(isinstance(cleaned_case['tags'], list))
        for tag in sample_case_data['tag']:
            expected_tag = TestTag.objects.get(name=tag)
            self.assertEqual(expected_tag, cleaned_case['tags'][0])
        self.assertEqual(sample_case_data['action'], cleaned_case['action'])
        self.assertEqual(sample_case_data['effect'], cleaned_case['effect'])
        self.assertEqual(sample_case_data['setup'], cleaned_case['setup'])
        self.assertEqual(sample_case_data['breakdown'],
                         cleaned_case['breakdown'])
        self.assertEqual(sample_case_data['notes'], cleaned_case['notes'])