def test_add_plan_entry_success(self): plan_entry = PlanEntry( suite_id=self.suite.id, include_all=True, case_ids=[self.case.id], config_ids=[self.config_ids[0], self.config_ids[1]], runs=[{ "config_ids": [self.config_ids[0]], "include_all": True }, { "config_ids": [self.config_ids[1]], "include_all": True }], name="Windows", ) plan_entry_added = self.client.add_plan_entry(self.plan.id, plan_entry) # check runs count self.attachments_page.assert_length(plan_entry_added.runs, 2) plan_entry = PlanEntry(id=plan_entry_added.id, name="config has been updated", suite_id=self.suite.id, config_ids=[ self.config_ids[0], self.config_ids[1], self.config_ids[2], self.config_ids[3], self.config_ids[4], self.config_ids[5] ]) updated_plan_entry = self.client.update_plan_entry( self.plan.id, plan_entry) # check runs count self.attachments_page.assert_length(updated_plan_entry.runs, 9)
def test_c5837_delete_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) config_id = self.config_ids[0] plan_entry = PlanEntry( suite_id=suite.id, include_all=True, config_ids=[config_id], runs=[dict(config_ids=[config_id], include_all=True)], name="Windows", ) plan_entry_added = self.client.add_plan_entry(plan.id, plan_entry) plan = self.client.get_plan(plan.id) assert len(plan.entries) == 1 assert plan.entries[0]["id"] == plan_entry_added.id self.client.delete_plan_entry(plan.id, plan_entry_added.id) updated_plan = self.client.get_plan(plan.id) assert len(updated_plan.entries) == 0
def test_add_plan_entry_remove_config(self): plan_entry = PlanEntry( suite_id=self.suite.id, include_all=True, case_ids=[self.case.id], config_ids=[self.config_ids[0], self.config_ids[1]], runs=[{ "config_ids": [self.config_ids[0]], "include_all": True }, { "config_ids": [self.config_ids[1]], "include_all": True }], name="Windows", ) plan_entry_added = self.client.add_plan_entry(self.plan.id, plan_entry) # check runs count self.attachments_page.assert_length(plan_entry_added.runs, 2) for config_group_id in self.config_group_ids: config_group = self.client.get_config_group(config_group_id) self.attachments_page.assert_length_equality( config_group.configs, self.groups_configs[config_group.name]) for idk in self.config_ids: deleted_config = self.client.delete_config(idk, check_errors=False) self.attachments_page.assert_response_code(deleted_config, 200) for config_group_id in self.config_group_ids: config_group = self.client.get_config_group(config_group_id) self.attachments_page.assert_length(config_group.configs, 0)
def add_plan_entry(self, plan_id, plan_entry, check_errors=True): response = self.client.send_post('add_plan_entry/{}'.format(plan_id), plan_entry, check_errors=check_errors) if 'response_code' in response.keys(): return response else: return PlanEntry(**response)
def test_update_plan_without_permissions(self): user = decode_data(str(self.users.regular_user)) user_overview_url = self.data.server_name + self.users.overview_url self.users_roles_page.open_page(user_overview_url) self.users_roles_page.add_user(user) role = decode_data(str(self.users.roles.no_permissions)) self.users_roles_page.open_page(self.data.server_name + self.users.add_role_url) self.users_roles_page.add_role(role) self.users_roles_page.open_page(user_overview_url) self.users_roles_page.select_user(self.users.regular_user.full_name) self.users_roles_page.open_access_tab() self.users_roles_page.change_role_for_user(role.name) original_username = self.client.client.username original_password = self.client.client.password self.client.client.username = user.email_address self.client.client.password = user.password try: plan_entry = PlanEntry( suite_id=self.suite.id, include_all=True, case_ids=[self.case.id], config_ids=[self.config_ids[0], self.config_ids[1]], runs=[{ "config_ids": [self.config_ids[0]], "include_all": True }, { "config_ids": [self.config_ids[1]], "include_all": True }], name="Windows", ) resp = self.client.add_plan_entry(self.plan.id, plan_entry, check_errors=False) self.attachments_page.assert_response_error( resp, self.attachments.errors.insufficient_permissions_msg) finally: self.client.client.username = original_username self.client.client.password = original_password
def test_c4047_add_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) config_ids = self.config_ids[:2] def make_run(id): return dict(config_ids=[id], include_all=True) plan_entry = PlanEntry( suite_id=suite.id, include_all=True, config_ids=[self.config_ids[0], self.config_ids[1]], runs=[make_run(id) for id in config_ids], name="Windows", ) plan_entry_added = self.client.add_plan_entry(plan.id, plan_entry) assert plan_entry_added.suite_id == plan_entry.suite_id assert plan_entry_added.name == plan_entry.name assert len(plan_entry_added.runs) == 2 # The order the runs come back in is not the same order as we sent # them, so we just check they're both included for run in plan_entry_added.runs: config_ids = run['config_ids'] assert len(config_ids) == 1 config_id = config_ids[0] assert config_id in config_ids config_ids.remove(config_id) assert run['include_all'] assert not run['is_completed'] assert run['plan_id'] == plan.id assert len(config_ids) == 0
def test_add_plan_entry_with_existing_user(self): plan_entry = PlanEntry( suite_id=self.suite.id, include_all=True, case_ids=[self.case.id], config_ids=[self.config_ids[0], self.config_ids[1]], runs=[{ "config_ids": [self.config_ids[0]], "include_all": True }, { "config_ids": [self.config_ids[1]], "include_all": True }], name="Windows", assignedto_id=1) plan_entry_added_resp = self.client.add_plan_entry(self.plan.id, plan_entry, check_errors=False) self.attachments_page.assert_equality( plan_entry_added_resp['response']['runs'][0]['assignedto_id'], plan_entry.assignedto_id)
def test_add_plan_entry_with_non_existing_user(self): plan_entry = PlanEntry( suite_id=self.suite.id, include_all=True, case_ids=[self.case.id], config_ids=[self.config_ids[0], self.config_ids[1]], runs=[{ "config_ids": [self.config_ids[0]], "include_all": True }, { "config_ids": [self.config_ids[1]], "include_all": True }], name="Windows", assignedto_id=999) plan_entry_added_resp = self.client.add_plan_entry(self.plan.id, plan_entry, check_errors=False) self.attachments_page.assert_response_code(plan_entry_added_resp, 400) self.attachments_page.assert_response_error( plan_entry_added_resp, self.attachments.errors.assignedto_is_not_valid_user)
class TestPlansAPI(APIBaseTest): suite_mode = 3 @pytest.mark.testrail(id=4046) def test_c4046_add_plan(self): plan = Plan(name="A Test Plan", description="A description of a test plan") created = self.client.add_plan(plan, self.project.id) assert created.name == plan.name assert created.description == plan.description @pytest.mark.testrail(id=4048) def test_c4048_get_plan(self): plan = Plan(name="A Test Plan", description="A description of a test plan") created = self.client.add_plan(plan, self.project.id) fetched = self.client.get_plan(created.id) assert fetched.name == created.name assert fetched.description == created.description @pytest.mark.testrail(id=4049) def test_c4049_update_plan(self): original = Plan(name="A Test Plan", description="A description of a test plan") created = self.client.add_plan(original, self.project.id) milestone = Milestone( name="A New Milestone", description="This is a description of a milestone") created_milestone = self.client.add_milestone(milestone, self.project.id) created.name = "A New Test Plan Name" created.description = "Something a bit different" created.milestone_id = created_milestone.id updated = self.client.update_plan(created) assert updated.name == created.name assert updated.description == created.description assert updated.milestone_id == created_milestone.id plan = self.client.get_plan(created.id) assert plan.name == updated.name assert plan.description == updated.description assert plan.milestone_id == updated.milestone_id @pytest.mark.testrail(id=4050) def test_c4050_get_plans(self): plans = self.client.get_plans(self.project.id) plan_ids = set(plan.id for plan in plans) plan = Plan(name="A New plan", description="This is a description of a plan") created = self.client.add_plan(plan, self.project.id) assert created.id not in plan_ids updated_plans = self.client.get_plans(self.project.id) updated_plan_ids = set(plan.id for plan in updated_plans) assert created.id in updated_plan_ids assert len(updated_plan_ids) == len(plan_ids) + 1 @pytest.mark.testrail(id=4051) def test_c4051_close_plan(self): original = Plan(name="A Test Plan", description="A description of a test plan") created = self.client.add_plan(original, self.project.id) updated = self.client.close_plan(created) assert updated.is_completed assert updated.completed_on > 0 plan = self.client.get_plan(created.id) assert plan.is_completed assert plan.completed_on > 0 @pytest.mark.testrail(id=5775) def test_c5775_delete_plan(self): plan = Plan(name="A New plan", description="This is a description of a plan") created = self.client.add_plan(plan, self.project.id) plans = self.client.get_plans(self.project.id) plan_ids = set(plan.id for plan in plans) assert created.id in plan_ids self.client.delete_plan(created) updated_plans = self.client.get_plans(self.project.id) updated_plan_ids = set(plan.id for plan in updated_plans) assert created.id not in updated_plan_ids assert len(updated_plans) == len(plans) - 1 @pytest.mark.testrail(id=4047) def test_c4047_add_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) config_ids = self.config_ids[:2] def make_run(id): return dict(config_ids=[id], include_all=True) plan_entry = PlanEntry( suite_id=suite.id, include_all=True, config_ids=[self.config_ids[0], self.config_ids[1]], runs=[make_run(id) for id in config_ids], name="Windows", ) plan_entry_added = self.client.add_plan_entry(plan.id, plan_entry) assert plan_entry_added.suite_id == plan_entry.suite_id assert plan_entry_added.name == plan_entry.name assert len(plan_entry_added.runs) == 2 # The order the runs come back in is not the same order as we sent # them, so we just check they're both included for run in plan_entry_added.runs: config_ids = run['config_ids'] assert len(config_ids) == 1 config_id = config_ids[0] assert config_id in config_ids config_ids.remove(config_id) assert run['include_all'] assert not run['is_completed'] assert run['plan_id'] == plan.id assert len(config_ids) == 0 @pytest.mark.testrail(id=5837) def test_c5837_delete_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) config_id = self.config_ids[0] plan_entry = PlanEntry( suite_id=suite.id, include_all=True, config_ids=[config_id], runs=[dict(config_ids=[config_id], include_all=True)], name="Windows", ) plan_entry_added = self.client.add_plan_entry(plan.id, plan_entry) plan = self.client.get_plan(plan.id) assert len(plan.entries) == 1 assert plan.entries[0]["id"] == plan_entry_added.id self.client.delete_plan_entry(plan.id, plan_entry_added.id) updated_plan = self.client.get_plan(plan.id) assert len(updated_plan.entries) == 0 @pytest.mark.testrail(id=5836) 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) plan_entry = PlanEntry(suite_id=suite.id, include_all=True, name="Windows", description="A test run") plan_entry = self.client.add_plan_entry(plan.id, plan_entry) plan_entry.name = "Linux" plan_entry.description = "A different test run" plan_entry.include_all = False plan_entry.case_ids = [case.id for case in cases[:2]]
def update_plan_entry(self, plan_id, plan_entry): response = self.client.send_post( 'update_plan_entry/{}/{}'.format(plan_id, plan_entry.id), plan_entry) return PlanEntry(**response)