Best Python code snippet using tempest_python
test_group_types.py
Source:test_group_types.py
...37 self.assertEqual(name, body['name'], err_msg % {"var": "name"})38 self.assertEqual(description, body['description'],39 err_msg % {"var": "description"})40 group_list = (41 self.admin_group_types_client.list_group_types()['group_types'])42 self.assertIsInstance(group_list, list)43 self.assertNotEmpty(group_list)44 update_params = {45 'name': data_utils.rand_name(46 self.__class__.__name__ + '-updated-group-type'),47 'description': 'updated-group-type-desc'48 }49 updated_group_type = self.admin_group_types_client.update_group_type(50 body['id'], **update_params)['group_type']51 for key, expected_val in update_params.items():52 self.assertEqual(expected_val, updated_group_type[key])53 fetched_group_type = self.admin_group_types_client.show_group_type(54 body['id'])['group_type']55 params.update(update_params) # Add updated params to original params.56 for key in params.keys():57 self.assertEqual(params[key], fetched_group_type[key],58 '%s of the fetched group_type is different '59 'from the created group_type' % key)60 self.admin_group_types_client.delete_group_type(body['id'])61 group_list = (62 self.admin_group_types_client.list_group_types()['group_types'])63 group_ids = [it['id'] for it in group_list]64 self.assertNotIn(body['id'], group_ids)65 @decorators.idempotent_id('3d5e5cec-72b4-4511-b135-7cc2b7a053ae')66 def test_group_type_list_by_optional_params(self):67 """Test list group type sort/public"""68 type_a_name = "a_{}".format(data_utils.rand_name('group-type'))69 type_b_name = "b_{}".format(data_utils.rand_name('group-type'))70 self.create_group_type(name=type_a_name, **{'is_public': True})71 self.create_group_type(name=type_b_name, **{'is_public': False})72 group_list = (73 self.admin_group_types_client.list_group_types(74 sort="name:asc", is_public=None)['group_types'])75 name_list = [it['name'] for it in group_list]76 self.assertLess(77 name_list.index(type_a_name), name_list.index(type_b_name))78 group_list = (79 self.admin_group_types_client.list_group_types(80 sort="name:desc", is_public=None)['group_types'])81 name_list = [it['name'] for it in group_list]82 self.assertLess(name_list.index(type_b_name),83 name_list.index(type_a_name))84 group_list = (85 self.admin_group_types_client.list_group_types(86 is_public=False)['group_types'])87 name_list = [it['name'] for it in group_list]88 self.assertNotIn(type_a_name, name_list)89 self.assertIn(type_b_name, name_list)90 group_list = (91 self.admin_group_types_client.list_group_types(92 is_public=True)['group_types'])93 name_list = [it['name'] for it in group_list]94 self.assertNotIn(type_b_name, name_list)...
group_ressources.py
Source:group_ressources.py
...57 }, 20058class GroupTypeListResource(WithGroupRepoResource):59 def get(self):60 return {61 "data": GroupService.list_group_types(current_app.context),62 "message": "success",63 }, 20064class PositionGroupTypeListResource(WithGroupRepoResource):65 """Get all groups66 ---67 get:68 tags:69 - groups70 security:71 - jwt: []72 parameters:73 - in: query74 name: groupType75 required: true...
group_service.py
Source:group_service.py
...11 with uow:12 groups: List[GroupEntity] = uow.group.get_all()13 return GroupService.schema(many=True).dump(groups)14 @staticmethod15 def list_group_types(uow: AbstractUnitOfWork) -> List[str]:16 return [e.value for e in list(GroupType)]17 @staticmethod18 def list_positions_by_group_types(group_type: GroupType, uow: AbstractUnitOfWork) -> List[Dict[str, Any]]:19 with uow:20 positions: List[PositionGroupTypeEntity] = uow.group.get_position_by_group_type(group_type=group_type)21 return PositionGroupTypeEntitySchema(many=True).dump(positions)22 @staticmethod23 def list_groups_from_type_and_query(group_type: GroupType, query: str, uow: AbstractUnitOfWork):24 with uow:25 groups: List[GroupEntity] = uow.group.get_from_group_type_and_query(group_type=group_type, query=query)26 return GroupService.schema(many=True).dump(groups)27 @staticmethod28 def list_location_by_query(query: str, uow: AbstractUnitOfWork) -> List[Dict[str, Any]]:29 with uow:...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!