Пример #1
0
    def test_missing_group_name(self):
        self.client.login(username=self.tester, password='******')

        response = self.client.get(self.group_add_url, {'action': 'add'})
        self.assertEqual({'rc': 1, 'response': 'Environment group name is required.'},
                         json_loads(response.content))

        response = self.client.get(self.group_add_url, {'action': 'add', 'name': ''})
        self.assertEqual({'rc': 1, 'response': 'Environment group name is required.'},
                         json_loads(response.content))
Пример #2
0
    def test_refuse_if_missing_property_name(self):
        self.client.login(username=self.tester.username, password='******')

        response = self.client.get(self.group_properties_url, {'action': 'add'})
        self.assertEqual({'rc': 1, 'response': 'Property name is required'},
                         json_loads(response.content))

        response = self.client.get(self.group_properties_url,
                                   {'action': 'add', 'name': ''})
        self.assertEqual({'rc': 1, 'response': 'Property name is required'},
                         json_loads(response.content))
Пример #3
0
    def test_refuse_if_missing_no_case_run_pk(self):
        self.client.login(username=self.tester.username, password='******')

        response = self.client.post(self.many_comments_url,
                                    {'comment': 'new comment', 'run': []})
        self.assertEqual({'rc': 1, 'response': 'No runs selected.'},
                         json_loads(response.content))

        response = self.client.post(self.many_comments_url,
                                    {'comment': 'new comment'})
        self.assertEqual({'rc': 1, 'response': 'No runs selected.'},
                         json_loads(response.content))
Пример #4
0
    def test_refuse_if_missing_comment(self):
        self.client.login(username=self.tester.username, password='******')

        response = self.client.post(self.many_comments_url,
                                    {'run': [self.case_run_1.pk, self.case_run_2.pk]})
        self.assertEqual({'rc': 1, 'response': 'Comments needed'},
                         json_loads(response.content))
Пример #5
0
    def test_remove_components(self):
        self.client.login(username=self.tester.username, password='******')

        user_should_have_perm(self.tester,
                              'testcases.delete_testcasecomponent')

        post_data = {
            'o_component': [self.comp_cli.pk, self.comp_api.pk],
            'case': [self.case_1.pk],
            'a': 'remove',
        }
        response = self.client.post(reverse('cases-remove-component'),
                                    post_data)

        data = json_loads(response.content)
        self.assertEqual(
            {
                'rc': 0,
                'response': 'Succeed to remove component(s) CLI, API.'
            }, data)

        for comp in (self.comp_cli, self.comp_api):
            case_components = TestCaseComponent.objects.filter(
                case=self.case_1, component=comp)
            self.assertFalse(case_components.exists())
Пример #6
0
 def test_refuse_when_missing_permission(self):
     response = self.client.get(self.group_modify_url,
                                {'action': 'modify',
                                 'id': self.group_nitrate.pk,
                                 'status': 0})
     self.assertEqual({'rc': 1, 'response': 'Permission denied.'},
                      json_loads(response.content))
Пример #7
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())
Пример #8
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())
Пример #9
0
    def test_missing_cases_ids(self):
        self.client.login(username=self.plan_tester.username, password='******')

        response = self.client.post(self.cases_url, {})
        data = json_loads(response.content)
        self.assertEqual(1, data['rc'])
        self.assertEqual('At least one case is required to re-order.', data['response'])
Пример #10
0
    def test_missing_permission(self):
        remove_perm_from_user(self.tester, self.permission)

        response = self.client.get(self.group_add_url,
                                   {'action': 'add', 'name': self.new_group_name})
        self.assertEqual({'rc': 1, 'response': 'Permission denied.'},
                         json_loads(response.content))
Пример #11
0
    def test_refuse_if_user_cannot_delete_file(self):
        self.client.login(username=self.anyone_else.username,
                          password=self.anyone_else_pwd)

        url = reverse('delete-file', args=[self.plan_attachment.pk])
        response = self.client.get(url, {'from_plan': self.plan.pk})

        self.assertEqual({'rc': 2, 'response': 'auth_failure'}, json_loads(response.content))
Пример #12
0
    def test_refuse_if_missing_permission(self):
        remove_perm_from_user(self.tester, self.permission)
        self.client.login(username=self.tester.username, password='******')

        response = self.client.get(self.group_properties_url,
                                   {'action': 'edit', 'id': self.property.pk})
        self.assertEqual({'rc': 1, 'response': 'Permission denied'},
                         json_loads(response.content))
Пример #13
0
    def test_search_all_cases(self):
        response = self.client.get(self.search_url, self.search_data)

        data = json_loads(response.content)

        cases_count = self.plan.case.count()
        self.assertEqual(cases_count, data['iTotalRecords'])
        self.assertEqual(cases_count, data['iTotalDisplayRecords'])
Пример #14
0
    def test_refuse_if_passed_case_run_pks_not_exist(self):
        self.client.login(username=self.tester.username, password='******')

        response = self.client.post(self.many_comments_url,
                                    {'comment': 'new comment',
                                     'run': '99999998,1009900'})
        self.assertEqual({'rc': 1, 'response': 'No caserun found.'},
                         json_loads(response.content))
Пример #15
0
    def test_refuse_if_property_id_not_exist(self):
        self.client.login(username=self.tester.username, password='******')

        response = self.client.get(self.group_properties_url,
                                   {'action': 'edit', 'id': 999999999})

        self.assertEqual({'rc': 1, 'response': 'ID does not exist.'},
                         json_loads(response.content))
Пример #16
0
    def test_refuse_if_missing_no_case_run_pk(self):
        self.client.login(username=self.tester.username, password='******')

        response = self.client.post(self.many_comments_url, {
            'comment': 'new comment',
            'run': []
        })
        self.assertEqual({
            'rc': 1,
            'response': 'No runs selected.'
        }, json_loads(response.content))

        response = self.client.post(self.many_comments_url,
                                    {'comment': 'new comment'})
        self.assertEqual({
            'rc': 1,
            'response': 'No runs selected.'
        }, json_loads(response.content))
Пример #17
0
    def test_get_env_properties(self):
        response = self.client.get(self.get_info_url, {'info_type': 'env_properties'})

        expected_json = json.loads(
            serializers.serialize(
                'json',
                TCMSEnvProperty.objects.all(),
                fields=('name', 'value')))
        self.assertEqual(expected_json, json_loads(response.content))
Пример #18
0
    def test_emtpy_plans(self):
        response = self.client.get(self.search_url, {})

        data = json_loads(response.content)

        self.assertEqual(0, data['sEcho'])
        self.assertEqual(0, data['iTotalRecords'])
        self.assertEqual(0, data['iTotalDisplayRecords'])
        self.assertEqual([], data['aaData'])
Пример #19
0
    def test_missing_cases_ids(self):
        self.client.login(username=self.plan_tester.username,
                          password='******')

        response = self.client.post(self.cases_url, {})
        data = json_loads(response.content)
        self.assertEqual(1, data['rc'])
        self.assertEqual('At least one case is required to re-order.',
                         data['response'])
Пример #20
0
    def test_get_env_properties(self):
        response = self.client.get(self.get_info_url,
                                   {'info_type': 'env_properties'})

        expected_json = json.loads(
            serializers.serialize('json',
                                  TCMSEnvProperty.objects.all(),
                                  fields=('name', 'value')))
        self.assertEqual(expected_json, json_loads(response.content))
Пример #21
0
    def test_emtpy_plans(self):
        response = self.client.get(self.search_url, {})

        data = json_loads(response.content)

        self.assertEqual(0, data['sEcho'])
        self.assertEqual(0, data['iTotalRecords'])
        self.assertEqual(0, data['iTotalDisplayRecords'])
        self.assertEqual([], data['aaData'])
Пример #22
0
    def test_delete_attachment_from_case(self):
        self.client.login(username=self.case_attachment.submitter.username,
                          password=self.submitter_pwd)

        url = reverse('delete-file', args=[self.case_attachment.pk])
        response = self.client.get(url, {'from_case': self.case_1.pk})

        self.assertEqual({'rc': 0, 'response': 'ok'}, json_loads(response.content))
        still_has = self.case_1.attachment.filter(pk=self.case_attachment.pk).exists()
        self.assertFalse(still_has)
Пример #23
0
    def test_refuse_if_missing_comment(self):
        self.client.login(username=self.tester.username, password='******')

        response = self.client.post(
            self.many_comments_url,
            {'run': [self.case_run_1.pk, self.case_run_2.pk]})
        self.assertEqual({
            'rc': 1,
            'response': 'Comments needed'
        }, json_loads(response.content))
Пример #24
0
    def test_manager_is_able_to_delete_without_requiring_permission(self):
        self.client.login(username=self.group_manager.username,
                          password='******')

        response = self.client.get(self.group_delete_url,
                                   {'action': 'del', 'id': self.group_nitrate.pk})

        self.assertEqual({'rc': 0, 'response': 'ok'}, json_loads(response.content))

        self.assertFalse(
            TCMSEnvGroup.objects.filter(pk=self.group_nitrate.pk).exists())
Пример #25
0
    def test_delete_group_by_non_manager(self):
        user_should_have_perm(self.tester, self.permission)
        self.client.login(username=self.tester.username, password='******')

        response = self.client.get(self.group_delete_url,
                                   {'action': 'del', 'id': self.group_fedora.pk})

        self.assertEqual({'rc': 0, 'response': 'ok'}, json_loads(response.content))

        self.assertFalse(
            TCMSEnvGroup.objects.filter(pk=self.group_fedora.pk).exists())
Пример #26
0
    def test_refuse_if_passed_case_run_pks_not_exist(self):
        self.client.login(username=self.tester.username, password='******')

        response = self.client.post(self.many_comments_url, {
            'comment': 'new comment',
            'run': '99999998,1009900'
        })
        self.assertEqual({
            'rc': 1,
            'response': 'No caserun found.'
        }, json_loads(response.content))
Пример #27
0
    def test_refuse_if_user_cannot_delete_file(self):
        self.client.login(username=self.anyone_else.username,
                          password=self.anyone_else_pwd)

        url = reverse('delete-file', args=[self.plan_attachment.pk])
        response = self.client.get(url, {'from_plan': self.plan.pk})

        self.assertEqual({
            'rc': 2,
            'response': 'auth_failure'
        }, json_loads(response.content))
Пример #28
0
    def test_refuse_invalid_status_value(self):
        user_should_have_perm(self.tester, self.permission)
        self.client.login(username=self.tester.username, password='******')

        # Status value is not valid as long as it's not 0 or 1.
        for invalid_status in ('true', 'false', 'yes', 'no', '2'):
            response = self.client.get(self.group_modify_url,
                                       {'action': 'modify',
                                        'id': self.group_nitrate.pk,
                                        'status': invalid_status})
            self.assertEqual({'rc': 1, 'response': 'Argument illegel.'},
                             json_loads(response.content))
Пример #29
0
    def test_get_env_properties_by_group(self):
        response = self.client.get(self.get_info_url, {
            'info_type': 'env_properties',
            'env_group_id': self.group_new.pk
        })

        group = TCMSEnvGroup.objects.get(pk=self.group_new.pk)
        expected_json = json.loads(
            serializers.serialize('json',
                                  group.property.all(),
                                  fields=('name', 'value')))
        self.assertEqual(expected_json, json_loads(response.content))
Пример #30
0
    def test_get_env_properties_by_group(self):
        response = self.client.get(self.get_info_url,
                                   {'info_type': 'env_properties',
                                    'env_group_id': self.group_new.pk})

        group = TCMSEnvGroup.objects.get(pk=self.group_new.pk)
        expected_json = json.loads(
            serializers.serialize(
                'json',
                group.property.all(),
                fields=('name', 'value')))
        self.assertEqual(expected_json, json_loads(response.content))
Пример #31
0
    def test_edit_a_property(self):
        self.client.login(username=self.tester.username, password='******')

        new_property_name = 'fedora-24'
        response = self.client.get(self.group_properties_url,
                                   {'action': 'edit',
                                    'id': self.property.pk,
                                    'name': new_property_name})

        self.assertEqual({'rc': 0, 'response': 'ok'}, json_loads(response.content))

        property = TCMSEnvProperty.objects.get(pk=self.property.pk)
        self.assertEqual(new_property_name, property.name)
Пример #32
0
    def test_add_existing_group(self):
        self.client.login(username=self.tester, password='******')

        self.client.get(self.group_add_url,
                        {'action': 'add', 'name': self.new_group_name})

        response = self.client.get(self.group_add_url,
                                   {'action': 'add', 'name': self.new_group_name})
        response_data = json_loads(response.content)
        self.assertIn(
            "Environment group name '{}' already".format(self.new_group_name),
            response_data['response']
        )
Пример #33
0
    def test_refuse_if_missing_permission(self):
        remove_perm_from_user(self.tester, self.permission)
        self.client.login(username=self.tester.username, password='******')

        response = self.client.post(self.update_url, {
            'content_type': 'testruns.testcaserun',
            'object_pk': self.case_run_1.pk,
            'field': 'case_run_status',
            'value': str(TestCaseRunStatus.objects.get(name='PAUSED').pk),
            'value_type': 'int',
        })

        self.assertEqual({'rc': 1, 'response': 'Permission Dinied.'},
                         json_loads(response.content))
Пример #34
0
    def test_change_case_run_status(self):
        self.client.login(username=self.tester.username, password='******')

        response = self.client.post(self.update_url, {
            'content_type': 'testruns.testcaserun',
            'object_pk': self.case_run_1.pk,
            'field': 'case_run_status',
            'value': str(TestCaseRunStatus.objects.get(name='PAUSED').pk),
            'value_type': 'int',
        })

        self.assertEqual({'rc': 0, 'response': 'ok'}, json_loads(response.content))
        self.assertEqual(
            'PAUSED', TestCaseRun.objects.get(pk=self.case_run_1.pk).case_run_status.name)
Пример #35
0
    def test_order_cases(self):
        self.client.login(username=self.plan_tester.username, password='******')

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

        self.assertEqual({'rc': 0, 'response': 'ok'}, data)

        case_plan_rel = TestCasePlan.objects.get(plan=self.plan, case=self.case_3)
        self.assertEqual(10, case_plan_rel.sortkey)

        case_plan_rel = TestCasePlan.objects.get(plan=self.plan, case=self.case_1)
        self.assertEqual(20, case_plan_rel.sortkey)
Пример #36
0
    def test_delete_attachment_from_case(self):
        self.client.login(username=self.case_attachment.submitter.username,
                          password=self.submitter_pwd)

        url = reverse('delete-file', args=[self.case_attachment.pk])
        response = self.client.get(url, {'from_case': self.case_1.pk})

        self.assertEqual({
            'rc': 0,
            'response': 'ok'
        }, json_loads(response.content))
        still_has = self.case_1.attachment.filter(
            pk=self.case_attachment.pk).exists()
        self.assertFalse(still_has)
Пример #37
0
    def test_return_empty_cases(self):
        url = reverse('cases-ajax-search')
        request = self.factory.get(url, {})
        request.user = self.tester

        empty_cases = TestCase.objects.none()
        response = ajax_response(request, empty_cases, self.column_names,
                                 self.template)

        data = json_loads(response.content)

        self.assertEqual(0, data['sEcho'])
        self.assertEqual(0, data['iTotalRecords'])
        self.assertEqual(0, data['iTotalDisplayRecords'])
        self.assertEqual([], data['aaData'])
Пример #38
0
    def test_refuse_to_create_duplicate_property(self):
        self.client.login(username=self.tester.username, password='******')

        request_data = {
            'action': 'add',
            'name': self.duplicate_property.name,
        }
        response = self.client.get(self.group_properties_url, request_data)

        expected_result = {
            'rc': 1,
            'response': "Environment property named '{}' already exists, "
                        "please select another name.".format(self.duplicate_property.name)
        }
        self.assertEqual(expected_result, json_loads(response.content))
Пример #39
0
    def test_update_plan_is_active(self):
        self.client.login(username=self.tester.username, password='******')

        post_data = {
            'content_type': 'testplans.testplan',
            'object_pk': self.plan.pk,
            'field': 'is_active',
            'value': 'False',
            'value_type': 'bool'
        }

        response = self.client.post(self.update_url, post_data)

        self.assertEqual({'rc': 0, 'response': 'ok'}, json_loads(response.content))
        plan = TestPlan.objects.get(pk=self.plan.pk)
        self.assertFalse(plan.is_active)
Пример #40
0
    def test_add_new_property(self):
        self.client.login(username=self.tester.username, password='******')

        new_property_name = 'f24'
        request_data = {
            'action': 'add',
            'name': new_property_name,
        }
        response = self.client.get(self.group_properties_url, request_data)

        self.assertTrue(TCMSEnvProperty.objects.filter(name=new_property_name).exists())

        new_property = TCMSEnvProperty.objects.get(name=new_property_name)
        self.assertEqual({'rc': 0, 'response': 'ok',
                          'name': new_property_name, 'id': new_property.pk},
                         json_loads(response.content))
Пример #41
0
    def test_order_cases(self):
        self.client.login(username=self.plan_tester.username,
                          password='******')

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

        self.assertEqual({'rc': 0, 'response': 'ok'}, data)

        case_plan_rel = TestCasePlan.objects.get(plan=self.plan,
                                                 case=self.case_3)
        self.assertEqual(10, case_plan_rel.sortkey)

        case_plan_rel = TestCasePlan.objects.get(plan=self.plan,
                                                 case=self.case_1)
        self.assertEqual(20, case_plan_rel.sortkey)
Пример #42
0
    def test_update_case_priority(self):
        self.client.login(username=self.tester.username, password='******')

        response = self.client.post(
            self.case_update_url,
            {
                'target_field': 'priority',
                'from_plan': self.plan.pk,
                'case': [self.case_1.pk, self.case_3.pk],
                'new_value': Priority.objects.get(value='P3').pk,
            })

        self.assertEqual({'rc': 0, 'response': 'ok'},
                         json_loads(response.content))

        for pk in (self.case_1.pk, self.case_3.pk):
            self.assertEqual('P3', TestCase.objects.get(pk=pk).priority.value)
Пример #43
0
    def test_refuse_if_missing_permission(self):
        remove_perm_from_user(self.tester, self.permission)
        self.client.login(username=self.tester.username, password='******')

        response = self.client.post(
            self.case_update_url,
            {
                'target_field': 'priority',
                'from_plan': self.plan.pk,
                'case': [self.case_1.pk, self.case_3.pk],
                'new_value': Priority.objects.get(value='P3').pk,
            })

        self.assertEqual(
            {'rc': 1, 'response': "You don't have enough permission to "
                                  "update TestCases."},
            json_loads(response.content))
Пример #44
0
    def test_refuse_if_missing_permission(self):
        remove_perm_from_user(self.tester, self.permission)
        self.client.login(username=self.tester.username, password='******')

        response = self.client.post(
            self.update_url, {
                'content_type': 'testruns.testcaserun',
                'object_pk': self.case_run_1.pk,
                'field': 'case_run_status',
                'value': str(TestCaseRunStatus.objects.get(name='PAUSED').pk),
                'value_type': 'int',
            })

        self.assertEqual({
            'rc': 1,
            'response': 'Permission Dinied.'
        }, json_loads(response.content))
Пример #45
0
    def test_refuse_if_missing_permission(self):
        self.client.login(username=self.tester.username, password='******')

        remove_perm_from_user(self.tester, self.permission)

        post_data = {
            'content_type': 'testplans.testplan',
            'object_pk': self.plan.pk,
            'field': 'is_active',
            'value': 'False',
            'value_type': 'bool'
        }

        response = self.client.post(self.update_url, post_data)

        self.assertEqual({'rc': 1, 'response': 'Permission Dinied.'},
                         json_loads(response.content))
Пример #46
0
    def test_update_case_priority(self):
        self.client.login(username=self.tester.username, password='******')

        response = self.client.post(
            self.case_update_url, {
                'target_field': 'priority',
                'from_plan': self.plan.pk,
                'case': [self.case_1.pk, self.case_3.pk],
                'new_value': Priority.objects.get(value='P3').pk,
            })

        self.assertEqual({
            'rc': 0,
            'response': 'ok'
        }, json_loads(response.content))

        for pk in (self.case_1.pk, self.case_3.pk):
            self.assertEqual('P3', TestCase.objects.get(pk=pk).priority.value)
Пример #47
0
    def test_update_cases_category(self):
        self.client.login(username=self.tester.username, password='******')

        post_data = {
            'from_plan': self.plan.pk,
            'product': self.product.pk,
            'case': [self.case_1.pk, self.case_3.pk],
            'a': 'update',
            'o_category': self.case_cat_full_auto.pk,
        }
        response = self.client.post(self.case_category_url, post_data)

        data = json_loads(response.content)
        self.assertEqual({'rc': 0, 'response': 'ok', 'errors_list': []}, data)

        for pk in (self.case_1.pk, self.case_3.pk):
            case = TestCase.objects.get(pk=pk)
            self.assertEqual(self.case_cat_full_auto, case.category)