def test_c5851_get_cases_with_combined_params(self, params, result):
        try:
            cases = self.client.get_cases(self.project.id)

            for item in cases:
                self.client.delete_case(item)

            for x in range(0, 10):
                case1 = Case(title='First new case',
                             type_id=7,
                             priority_id=2,
                             estimate='2m')
                self.client.add_case(case1, self.section.id)

                case2 = Case(title='Second new case',
                             type_id=7,
                             priority_id=2,
                             estimate='2m')
                self.client.add_case(case2, self.section.id)

            cases = self.client.get_cases(self.project.id, **params)

            assert len(cases) == result[0]
            for item in cases:
                assert result[1] in item.title
        finally:
            to_delete = self.client.get_cases(self.project.id)
            for item in to_delete:
                self.client.delete_case(item)
class TestCasesAPI(APIBaseTest):
    @classmethod
    def setup_class(cls):
        super().setup_class()
        section = Section(name="Some Section")
        created = cls.client.add_section(section, cls.project.id)
        cls.section = created
        cls.add_user_with_permissions()
        cls.second_client = make_client(cls.user.email_address,
                                        cls.user.password)

    @classmethod
    def teardown_class(cls):
        cls.delete_user()
        super().teardown_class()

    @pytest.mark.testrail(id=4033)
    def test_c4033_add_case(self):
        case = Case(title="A New Case",
                    type_id=7,
                    priority_id=2,
                    estimate="10m")
        created = self.client.add_case(case, self.section.id)

        assert created.title == case.title
        assert created.section_id == self.section.id
        assert created.type_id == case.type_id
        assert created.priority_id == case.priority_id
        assert created.estimate == case.estimate
Exemple #3
0
 def test_c4071_c4072_get_test_get_tests(self):
     # get_test and get_tests are also extensively exercised by test_runs_and_results
     section = Section(name="Some Section")
     section = self.client.add_section(section, self.project.id)
     cases = []
     for title in ["Case 1", "Case 2", "Case 3"]:
         case = Case(title=title, type_id=7, priority_id=2, estimate="10m")
         case = self.client.add_case(case, section.id)
         cases.append(case)
Exemple #4
0
    def setup_class(cls):
        super().setup_class()

        section = Section(name="Some Section")
        created = cls.client.add_section(section, cls.project.id)
        cls.section = created
        cls.cases = []
        for title in ["Case 1", "Case 2", "Case 3"]:
            case = Case(title=title, type_id=7, priority_id=2, estimate="10m")
            case = cls.client.add_case(case, cls.section.id)
            cls.cases.append(case)
    def test_c5848_get_cases_with_filter_utf8(self, params):
        try:
            case = Case(title='łŻ∂ąś∆īp',
                        type_id=7,
                        priority_id=2,
                        estimate='10m')
            reference = self.client.add_case(case, self.section.id)
            result = reference

            cases = self.client.get_cases(self.project.id, **params)
            assert result in cases
    def test_c5953_get_cases_offset_char(self, params, result):
        try:
            case = Case(title='First new case',
                        type_id=7,
                        priority_id=2,
                        estimate='2m')
            self.client.add_case(case, self.section.id)

            with pytest.raises(APIError) as e_info:
                self.client.get_cases(self.project.id, **params)

            error = e_info.value
            assert error.status_code == result[0]
            assert error.error == result[1]
 def test_c5849_get_cases_with_limit_and_offset(self, params, result):
     try:
         case1 = Case(title='First new case',
                      type_id=7,
                      priority_id=2,
                      estimate='10m')
         case2 = Case(title='Second new case',
                      type_id=7,
                      priority_id=2,
                      estimate='10m')
         case3 = Case(title='Third new case',
                      type_id=7,
                      priority_id=2,
                      estimate='10m')
         self.client.add_case(case1, self.section.id)
         self.client.add_case(case2, self.section.id)
         self.client.add_case(case3, self.section.id)
         cases = self.client.get_cases(self.project.id, **params)
         assert result in cases[0].title
     finally:
         to_delete = self.client.get_cases(self.project.id)
         for item in to_delete:
             self.client.delete_case(item)
    def test_c5836_update_plan_entry(self):
        self.add_configs()

        suite = Suite(name="Test Suite")
        suite = self.client.add_suite(suite, self.project.id)
        section = Section(name="Test Section", suite_id=suite.id)
        section = self.client.add_section(section, self.project.id)
        plan = Plan(name="Test Plan")
        plan = self.client.add_plan(plan, self.project.id)

        cases = []
        for title in ["Case 1", "Case 2", "Case 3"]:
            case = Case(title=title, type_id=7, priority_id=2, estimate="10m")
            case = self.client.add_case(case, section.id)
            cases.append(case)
    def test_c5850_get_cases_with_limit(self, params, result):
        try:
            case = Case(title='First new case',
                        type_id=7,
                        priority_id=2,
                        estimate='10m')
            self.client.add_case(case, self.section.id)
            self.client.add_case(case, self.section.id)

            cases = self.client.get_cases(self.project.id, **params)
            assert len(cases) == result

            self.client.add_case(case, self.section.id)

            updated_cases = self.client.get_cases(self.project.id, **params)
            assert len(updated_cases) == result
Exemple #10
0
    def test_c5955_get_cases_offset_too_big(self, params):
        try:
            cases = self.client.get_cases(self.project.id)
            if len(cases) == 0:
                for x in range(0, 5):
                    case = Case(title='First new case',
                                type_id=7,
                                priority_id=2,
                                estimate='2m')
                    self.client.add_case(case, self.section.id)

            cases = self.client.get_cases(self.project.id)

            result = ([] if 'limit' in params.keys() else cases)
            params['offset'] = len(cases)
            filtered_cases = self.client.get_cases(self.project.id, **params)
            assert filtered_cases == result
Exemple #11
0
    def test_4045_update_case(self):
        original = Case(title="A New Case",
                        type_id=7,
                        priority_id=2,
                        estimate="10m")
        created = self.client.add_case(original, self.section.id)

        created.title = "A New Title"
        created.estimate = "5s"
        updated = self.client.update_case(created)

        assert updated.title == created.title
        assert updated.estimate == created.estimate

        case = self.client.get_case(created.id)
        assert case.title == updated.title
        assert case.estimate == updated.estimate
Exemple #12
0
    def prepare_test_case(cls):
        # Add Config Groups and Configs
        cls.add_configs()

        # add test Suite
        suite = Suite(name="Test Suite")
        cls.suite = cls.client.add_suite(suite, cls.project.id)

        # add Section
        section = Section(name="Test Section", suite_id=cls.suite.id)
        section_created = cls.client.add_section(section, cls.project.id)
        cls.section = section_created

        # add test case
        case = Case(title="Test Case")
        cls.case = cls.client.add_case(case, section_created.id)

        # add Test Plan
        plan = Plan(name="Test Plan")
        cls.plan = cls.client.add_plan(plan, cls.project.id)
    def prepare_test_case(cls):
        cls.projects_created = []

        # add project
        added_project = Project(name="New Project",
                                announcement="Some announcement",
                                show_announcement=False,
                                suite_mode=1)
        project_created = cls.client.add_project(added_project)
        cls.projects_created.append(project_created)
        cls.project_new = project_created

        # add Section
        section = Section(name="Test Section")
        section_created = cls.client.add_section(section, project_created.id)
        cls.section = section_created

        # add test case
        case = Case(title="Test Case")
        cls.case = cls.client.add_case(case, section_created.id)

        # add test Run
        run = Run(name="Test Run")
        cls.run = cls.client.add_run(run, project_created.id)
Exemple #14
0
class APIClient(object):
    def __init__(self, config):
        self.client = Client(config)

    def get_priorities(self):
        response = self.client.send_get('get_priorities')
        return [Priority(**args) for args in response]

    def get_statuses(self):
        response = self.client.send_get('get_statuses')
        return [Status(**args) for args in response]

    def get_templates(self, project_id):
        response = self.client.send_get(f'get_templates/{project_id}')
        return [Template(**args) for args in response]

    def add_project(self, project):
        response = self.client.send_post('add_project', project)
        return Project(**response)

    def get_projects(self):
        response = self.client.send_get('get_projects')
        return [Project(**args) for args in response]

    def get_project(self, id):
        response = self.client.send_get('get_project/{}'.format(id))
        return Project(**response)

    def delete_project(self, project):
        self.client.send_post('delete_project/{}'.format(project.id))

    def update_project(self, project):
        response = self.client.send_post(
            'update_project/{}'.format(project.id), project)
        return Project(**response)

    def add_run(self, run, project_id):
        response = self.client.send_post('add_run/{}'.format(project_id), run)
        return Run(**response)

    def get_run(self, run_id):
        response = self.client.send_get(f'get_run/{run_id}')
        return Run(**response)

    def get_runs(self, project_id, **kwargs):
        response = self.client.send_get(f'get_runs/{project_id}',
                                        params=kwargs)
        return [Run(**args) for args in response]

    def update_run(self, run):
        response = self.client.send_post(f'update_run/{run.id}', run)
        return Run(**response)

    def delete_run(self, run):
        self.client.send_post('delete_run/{}'.format(run.id))

    def close_run(self, run):
        response = self.client.send_post('close_run/{}'.format(run.id))
        return Run(**response)

    def add_suite(self, suite, project_id):
        response = self.client.send_post('add_suite/{}'.format(project_id),
                                         suite)
        return Suite(**response)

    def get_suite(self, suite_id):
        response = self.client.send_get(f'get_suite/{suite_id}')
        return Suite(**response)

    def get_suites(self, project_id):
        response = self.client.send_get(f'get_suites/{project_id}')
        return [Suite(**args) for args in response]

    def update_suite(self, suite):
        response = self.client.send_post(f'update_suite/{suite.id}', suite)
        return Suite(**response)

    def delete_suite(self, suite):
        self.client.send_post(f'delete_suite/{suite.id}')

    def add_section(self, section, project_id):
        response = self.client.send_post('add_section/{}'.format(project_id),
                                         section)
        return Section(**response)

    def get_section(self, section_id):
        response = self.client.send_get(f'get_section/{section_id}')
        return Section(**response)

    def get_sections(self, project_id):
        response = self.client.send_get(f'get_sections/{project_id}')
        return [Section(**args) for args in response]

    def update_section(self, section):
        response = self.client.send_post(f'update_section/{section.id}',
                                         section)
        return Section(**response)

    def delete_section(self, section):
        self.client.send_post(f'delete_section/{section.id}')

    def add_milestone(self, milestone, project_id):
        response = self.client.send_post(f'add_milestone/{project_id}',
                                         milestone)
        return Milestone(**response)

    def get_milestone(self, milestone_id):
        response = self.client.send_get(f'get_milestone/{milestone_id}')
        return Milestone(**response)

    def get_milestones(self, project_id):
        response = self.client.send_get(f'get_milestones/{project_id}')
        return [Milestone(**args) for args in response]

    def update_milestone(self, milestone):
        response = self.client.send_post(f'update_milestone/{milestone.id}',
                                         milestone)
        return Milestone(**response)

    def delete_milestone(self, milestone):
        self.client.send_post(f'delete_milestone/{milestone.id}')

    def add_case(self, case, section_id):
        response = self.client.send_post('add_case/{}'.format(section_id),
                                         case)
        return Case(**response)
Exemple #15
0
 def get_cases(self, project_id, **kwargs):
     response = self.client.send_get(f'get_cases/{project_id}',
                                     params=kwargs)
     return [Case(**args) for args in response]
Exemple #16
0
 def update_case(self, case):
     response = self.client.send_post(f'update_case/{case.id}', case)
     return Case(**response)
Exemple #17
0
                    estimate="10m")
        created = self.client.add_case(case, self.section.id)

        assert created.title == case.title
        assert created.section_id == self.section.id
        assert created.type_id == case.type_id
        assert created.priority_id == case.priority_id
        assert created.estimate == case.estimate

    @pytest.mark.testrail(id=4043)
    def test_c4043_get_cases(self):
        cases = self.client.get_cases(self.project.id)
        case_ids = set(case.id for case in cases)

        case = Case(title="A New Case",
                    type_id=7,
                    priority_id=2,
                    estimate="10m")
        created = self.client.add_case(case, self.section.id)

        assert created.id not in case_ids
        updated_cases = self.client.get_cases(self.project.id)
        updated_case_ids = set(case.id for case in updated_cases)
        assert created.id in updated_case_ids
        assert len(updated_cases) == len(cases) + 1

    @pytest.mark.testrail(id=4044)
    def test_4044_get_case(self):
        case = Case(title="A New Case",
                    type_id=7,
                    priority_id=2,
                    estimate="10m")
Exemple #18
0
 def get_case(self, case_id):
     response = self.client.send_get(f'get_case/{case_id}')
     return Case(**response)