Untitled

Delete Code and Output
mail@pastecode.io avatar
unknown
python
2 years ago
2.4 kB
1
Indexable
Never
@router.delete(
        "/api/groups/{group_id}/user/{user_id}", 
        alias = "/api/groups/{group_id}/users/{user_id}",
        require_admin=True, 
        summary="Removes a user from a group")
    def delete(
        self,
        trans: ProvidesAppContext = DependsOnTrans,
        group_id: EncodedDatabaseIdField = GroupIDParam,
        user_id: EncodedDatabaseIdField = UserIDParam,
    ) -> GroupUserModel:
        """
        DELETE /api/groups/{encoded_group_id}/users/{encoded_user_id}
        Removes a user from a group
        """
        user = self.manager.delete(trans, user_id, group_id)
        return group_user_to_model(trans, group_id, user)

--------------------------------------------------------------------------------------------------
Test Output
self = <galaxy_test.api.test_group_users.GroupUsersApiTestCase testMethod=test_delete>

    def test_delete(self):
        group_name = "group-with-user-to-delete"
        encoded_user_id = self.dataset_populator.user_id()
        group = self._create_group(group_name, encoded_user_ids=[encoded_user_id])
        encoded_group_id = group["id"]
    
        group_users = self._get_group_users(encoded_group_id)
        assert len(group_users) == 1
    
        delete_response = self._delete(f"groups/{encoded_group_id}/users/{encoded_user_id}", admin=True)
        self._assert_status_code_is_ok(delete_response)
        group_user = delete_response.json()
>       self._assert_valid_group_user(group_user, assert_id=encoded_user_id)

lib/galaxy_test/api/test_group_users.py:92: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <galaxy_test.api.test_group_users.GroupUsersApiTestCase testMethod=test_delete>
user = {'email': 'user@bx.psu.edu', 'id': 'eb142648ac45b77086610f67617bec2ad3808fd4409d175f', 'url': '/api/groups/adb5f5c93f827949/users/eb142648ac45b77086610f67617bec2ad3808fd4409d175f'}
assert_id = 'adb5f5c93f827949'

    def _assert_valid_group_user(self, user, assert_id=None):
        self._assert_has_keys(user, "id", "email", "url")
        if assert_id is not None:
>           assert user["id"] == assert_id
E           AssertionError: assert 'eb142648ac45...08fd4409d175f' == 'adb5f5c93f827949'
E             - adb5f5c93f827949
E             + eb142648ac45b77086610f67617bec2ad3808fd4409d175f

lib/galaxy_test/api/test_group_users.py:137: AssertionError