Пример #1
0
def test_uploader_identity_ensure_member_can_be_removed_wrong_identity(
    uploader_identity: UploaderIdentity, ) -> None:
    member = UploaderIdentityMemberFactory(
        role=UploaderIdentityMemberRole.member)
    assert uploader_identity.can_member_be_removed(member) is False
    with pytest.raises(ValidationError) as e:
        uploader_identity.ensure_member_can_be_removed(member)
    assert "Member is not a part of this uploader identity" in str(e.value)
Пример #2
0
def test_uploader_identity_ensure_member_can_be_removed_last_owner(
    uploader_identity: UploaderIdentity, ) -> None:
    owner = UploaderIdentityMemberFactory(
        identity=uploader_identity,
        role=UploaderIdentityMemberRole.owner,
    )
    assert uploader_identity.members.count() == 1
    assert uploader_identity.can_member_be_removed(owner) is False
    with pytest.raises(ValidationError) as e:
        uploader_identity.ensure_member_can_be_removed(owner)
    assert "Cannot remove last owner from team" in str(e.value)
Пример #3
0
def test_uploader_identity_ensure_member_can_be_removed(
        uploader_identity: UploaderIdentity, role: str) -> None:
    member = UploaderIdentityMemberFactory(
        role=role,
        identity=uploader_identity,
    )
    if role == UploaderIdentityMemberRole.owner:
        UploaderIdentityMemberFactory(
            identity=uploader_identity,
            role=UploaderIdentityMemberRole.owner,
        )
    assert uploader_identity.can_member_be_removed(member) is True
    uploader_identity.ensure_member_can_be_removed(member)
Пример #4
0
def test_uploader_identity_ensure_member_can_be_removed_no_member(
    uploader_identity: UploaderIdentity, ) -> None:
    assert uploader_identity.can_member_be_removed(None) is False
    with pytest.raises(ValidationError) as e:
        uploader_identity.ensure_member_can_be_removed(None)
    assert "Invalid member" in str(e.value)