def immutable_role(immutable_group_with_child): data = { "$name": random_string(), "$groupId": immutable_group_with_child['groupId'] } response = send_request.post(mgr.roles, data) yield response.json() send_request.delete(mgr.roles, id_to_url=response.json()['roleId'])
def immutable_group_with_child(): """ :return: {} """ groups_id = deque([], maxlen=5) data = {"$name": random_string(), "$parentGroupId": root_group_id()} response_parent = send_request.post(mgr.groups, data) groups_id.appendleft(response_parent.json()['groupId']) data_child = {"$name": random_string(), "$parentGroupId": groups_id[0]} response_child = send_request.post(mgr.groups, data_child) response = send_request.get(mgr.groups, id_to_url=groups_id[0]) groups_id.appendleft(response_child.json()['groupId']) yield response.json() for i in groups_id: send_request.delete(mgr.groups, id_to_url=i)
def test_delete_group_with_child(self, immutable_group_with_child): group_id = immutable_group_with_child['groupId'] response = send_request.delete(mgr.groups, id_to_url=group_id) expected_response = { 'COMMON_NOT_ALLOWED_OPERATION': 'The group has subgroups' } assert (response.status_code, response.json()) == (400, expected_response)
def test_delete_user_by_unknown_userId(self): unknown_user_id = random_string() response = send_request.delete(mgr.users, id_to_url=unknown_user_id) expected_response = { 'COMMON_REQUESTED_RESOURCES_NOT_FOUND': 'USER not found by userId=%s' % unknown_user_id } assert (response.json(), response.status_code) == (expected_response, 400)
def test_delete_role_by_unknown_id(self): unknown_role_id = random_string() response = send_request.delete(mgr.roles, id_to_url=unknown_role_id) expected_response = { 'COMMON_REQUESTED_RESOURCES_NOT_FOUND': 'ROLE by roleId=%s not found' % unknown_role_id } assert (response.status_code, response.json()) == (400, expected_response)
def test_delete_group_with_unknown_id(self): unknown_group_id = random_string() response = send_request.delete(mgr.groups, id_to_url=unknown_group_id) expected_response = { 'COMMON_REQUESTED_RESOURCES_NOT_FOUND': 'GROUP by groupId=%s not found' % unknown_group_id } assert (response.status_code, response.json()) == (400, expected_response)
def immutable_user(userGroupRoles, immutable_role): data = { "$login": random_string(), "$fname": random_string(), "$lname": random_string(), "$roleId": immutable_role['roleId'], "$agentId": random_string(), "$ADlogin": random_string(), "$pname": random_string(), "$email": random_string() + '@.com.ua', "$phone": str(random.randint(11111, 99999999)), "$fax": random_string(), "$userGroupRoles": userGroupRoles } response = send_request.post(mgr.users, data) user = response.json() user['dateCreate'] = round(user['dateCreate'] / 1000) * 1000 yield user send_request.delete(mgr.users, id_to_url=response.json()['userId'])
def role(group): data = {"$name": random_string(), "$groupId": group['groupId']} response = send_request.post(mgr.roles, data) yield response.json() send_request.delete(mgr.roles, id_to_url=response.json()['roleId'])
def fin(): send_request.delete(mgr.users, id_to_url=user['userId'])
def group(): data = {"$name": random_string(), "$parentGroupId": root_group_id()} response = send_request.post(mgr.groups, data) yield response.json() send_request.delete(mgr.groups, id_to_url=response.json()['groupId'])
def test_delete_user_enabled_false(self, add_user_with_role): disabled_user = add_user_with_role(enabled=False) response = send_request.delete(mgr.users, id_to_url=disabled_user['userId']) assert (response.json(), response.status_code) == (disabled_user, 200)
def test_delete_user(self, user): response = send_request.delete(mgr.users, id_to_url=user['userId']) assert (response.json(), response.status_code) == (user, 200)
def test_delete_role(self, role): role.pop("templateRole") response = send_request.delete(mgr.roles, id_to_url=role['roleId']) assert (response.status_code, response.json()) == (200, role)
def test_delete_group(self, group): response = send_request.delete(mgr.groups, id_to_url=group['groupId']) assert (response.status_code, response.json()) == (200, group)