Example #1
0
    def test_member_not_found(self, ctx,
                              mock_member_repository: MemberRepository,
                              member_manager: MemberManager):
        # Given...
        mock_member_repository.get_by_id = MagicMock(
            return_value=(None), side_effect=MemberNotFoundError(""))

        # When...
        with pytest.raises(MemberNotFoundError):
            member_manager.get_profile(ctx)

        # Expect...
        mock_member_repository.get_by_id.assert_called_once_with(
            ctx, ctx.get(CTX_ADMIN))
Example #2
0
    def test_happy_path(self, ctx, mock_member_repository: MemberRepository,
                        sample_member: Member, member_manager: MemberManager):
        # Given...
        mock_member_repository.get_by_id = MagicMock(
            return_value=(sample_member))

        # When...
        m, roles = member_manager.get_profile(ctx)

        # Expect...
        assert sample_member == m
        assert len(roles) == len(ctx.get(CTX_ROLES))
        assert len(roles) == len(set(roles) & set(ctx.get(CTX_ROLES)))
        mock_member_repository.get_by_id.assert_called_once_with(
            ctx, ctx.get(CTX_ADMIN))