reviewboard.reviews.testing.queries.review_requests¶
Testing utilities for building expected queries for review requests.
New in version 5.0.7.
- get_review_requests_accessible_q(*, user: Optional[Union[AnonymousUser, User]], local_site: AnyOrAllLocalSites = None, has_local_sites_in_db: bool = False, show_all_unpublished: bool = False, show_inactive: bool = False, filter_private: bool = False, status: Optional[str] = 'P', extra_query: Q = <Q: (AND: )>, accessible_repository_ids: Sequence[int] = [], accessible_review_group_ids: Sequence[int] = [], needs_local_site_profile_query: bool = False, needs_user_permission_queries: bool = True) ExpectedQResult [source]¶
Return a Q expression for accessible review request queries.
New in version 5.0.7.
- Parameters:
user (
django.contrib.auth.models.AnonymousUser
or :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:``django.contrib.auth.models.User
) – The user that’s checked for access.local_site (
reviewboard.site.models.LocalSite
, optional) – The optional Local Site value used in the queries.has_local_sites_in_db (
bool
, optional) – Whether the query expects Local Sites to be in the database.show_all_unpublished (
bool
, optional) – Whether unpublished review requests would be allowed in the results.show_inactive (
bool
, optional) – Whether review requests from inactive users would be allowed in the results.filter_private (
bool
, optional) – Whether review requests would be filtered using ACL checks.status (
str
, optional) – The optional status that would be used in the query.extra_query (
django.db.models.Q
, optional) – An extra query filter that would be included.accessible_repository_ids (
list
ofint
, optional) – A list of accessible repository IDs that would be expected in the query.accessible_review_group_ids (
list
ofint
, optional) – A list of accessible review group IDs that would be expected in the query.needs_local_site_profile_query (
bool
, optional) –Whether the query should fetch a
LocalSiteProfile
.Set this to
False
if this should be cached at this point.needs_user_permission_queries (
bool
, optional) –Whether the query should check for the
reviews.can_view_invite_only_groups
permission.Set to
False
if this is already cached at this point.
- Returns:
The expected Q results.
- Return type:
- get_review_requests_from_user_q(*, from_user: Union[str, User], **kwargs: Unpack[_AccessibleKwargs]) ExpectedQResult [source]¶
Return a Q expression for review requests from a user.
This corresponds to a call from
ReviewRequest.objects.from_user()
.It wraps
get_review_requests_accessible_q()
and takes all the same arguments.New in version 5.0.7.
- Parameters:
from_user (
str
ordjango.contrib.auth.models.User
) – The username or user that review requests would be published from for the query.**kwargs (
dict
) – Keyword arguments to pass toget_review_requests_accessible_q()
.
- Returns:
The expected Q results.
- Return type:
- get_review_requests_to_group_q(*, to_group_name: str, **kwargs: Unpack[_AccessibleKwargs]) ExpectedQResult [source]¶
Return a Q expression for review requests to a group.
This corresponds to a call from
ReviewRequest.objects.to_group()
.It wraps
get_review_requests_accessible_q()
and takes all the same arguments.New in version 5.0.7.
- Parameters:
to_group_name (
str
) – The name of the group.**kwargs (
dict
) – Keyword arguments to pass toget_review_requests_accessible_q()
.
- Returns:
The expected Q results.
- Return type:
- get_review_requests_to_user_q(*, to_user: Union[str, User], to_user_profile: Optional[Profile], target_groups: Sequence[Group] = [], **kwargs: Unpack[_AccessibleKwargs]) ExpectedQResult [source]¶
Return a Q expression for review requests to a user.
This corresponds to a call from
ReviewRequest.objects.to_user()
.It wraps
get_review_requests_accessible_q()
and takes all the same arguments.The
prep_equeries
key of the result must immediately precede any Usage of the resulting Q-expression.New in version 5.0.7.
- Parameters:
to_user (
str
ordjango.contrib.auth.models.User
) – The username or user that review requests would be assigned to.to_user_profile (
reviewboard.accounts.models.Profile
) – The profile of the user that review requests would be assigned to.target_groups (
list
ofreviewboard.reviews.models.group.Group
) – The list of review groups that the user may be a member of, for the query.**kwargs (
dict
) – Keyword arguments to pass toget_review_requests_accessible_q()
.
- Returns:
The expected Q results.
- Return type:
- get_review_requests_to_user_directly_q(*, to_user: Union[str, User], to_user_profile: Optional[Profile], subquery_start_index: int = 1, **kwargs: Unpack[_AccessibleKwargs]) ExpectedQResult [source]¶
Return a Q expression for review requests directly to a user.
This corresponds to a call from
ReviewRequest.objects.to_user_directly()
.It wraps
get_review_requests_accessible_q()
and takes all the same arguments.New in version 5.0.7.
- Parameters:
to_user (
str
ordjango.contrib.auth.models.User
) – The username or user that review requests would be assigned to.to_user_profile (
reviewboard.accounts.models.Profile
) – The profile of the user that review requests would be assigned to.subquery_start_index (
int
, optional) – The starting index for any subquery markers, to ease embedding in another query.**kwargs (
dict
) – Keyword arguments to pass toget_review_requests_accessible_q()
.
- Returns:
The expected Q results.
- Return type:
- get_review_requests_to_user_groups_q(*, to_user: Union[str, User], to_user_profile: Optional[Profile], target_groups: Sequence[Group] = [], **kwargs: Unpack[_AccessibleKwargs]) ExpectedQResult [source]¶
Return a Q expression for review requests to a user’s groups.
This corresponds to a call from
ReviewRequest.objects.to_user_groups()
.It wraps
get_review_requests_accessible_q()
and takes all the same arguments.The
prep_equeries
key of the result must immediately precede any Usage of the resulting Q-expression.New in version 5.0.7.
- Parameters:
to_user (
str
ordjango.contrib.auth.models.User
) – The username or user belonging to a group that review requests would be assigned to.to_user_profile (
reviewboard.accounts.models.Profile
) – The profile of the user belonging to a group that review requests would be assigned to.target_groups (
list
ofreviewboard.reviews.models.group.Group
) – The list of review groups that the user may be a member of, for the query.**kwargs (
dict
) – Keyword arguments to pass toget_review_requests_accessible_q()
.
- Returns:
The expected Q results.
- Return type:
- get_review_requests_to_or_from_user_q(*, to_or_from_user: Union[str, User], to_or_from_user_profile: Optional[Profile], target_groups: Sequence[Group] = [], **kwargs: Unpack[_AccessibleKwargs]) ExpectedQResult [source]¶
Return a Q expression for review requests to/from a user.
This corresponds to a call from
ReviewRequest.objects.to_or_from_user()
.It wraps
get_review_requests_accessible_q()
and takes all the same arguments.The
prep_equeries
key of the result must immediately precede any Usage of the resulting Q-expression.New in version 5.0.7.
- Parameters:
to_or_from_user (
str
ordjango.contrib.auth.models.User
) – The username or user that review requests would be assigned to or posted from.to_or_from_user_profile (
reviewboard.accounts.models.Profile
) – The profile of the user that review requests would be assigned to or posted from.target_groups (
list
ofreviewboard.reviews.models.group.Group
) – The list of review groups that the user may be a member of, for the query.**kwargs (
dict
) – Keyword arguments to pass toget_review_requests_accessible_q()
.
- Returns:
The expected Q results.
- Return type:
- get_review_requests_accessible_prep_equeries(*, user: Union[AnonymousUser, User], local_site: AnyOrAllLocalSites = None, needs_local_site_profile_query: bool = True, needs_user_permission_queries: bool = True) ExpectedQueries [source]¶
Return expected review request accessibility preparation queries.
These are queries that must be performed before the main accessibility query is executed.
New in version 5.0.7.
- Parameters:
user (
django.contrib.auth.models.AnonymousUser
or :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:``django.contrib.auth.models.User
) – The user that’s checked for access.local_site (
reviewboard.site.models.LocalSite
, optional) – The optional Local Site value used in the queries.needs_local_site_profile_query (
bool
, optional) –Whether the query should fetch a
LocalSiteProfile
.Set to
False
if this should be cached at this point.needs_user_permission_queries (
bool
, optional) –Whether the query should check for the
reviews.can_view_invite_only_groups
permission.Set to
False
if this is already cached at this point.
- Returns:
The list of expected queries.
- Return type:
- get_review_requests_accessible_equeries(*, distinct: bool = False, **kwargs: Unpack[_AccessibleKwargs]) ExpectedQueries [source]¶
Return queries for accessible review requests.
This corresponds to a call from
ReviewRequest.objects.public()
.New in version 5.0.7.
- Parameters:
distinct (
bool
, optional) – Whether this is a distinct query.**kwargs (
dict
, optional) – Keyword arguments to pass toget_review_requests_accessible_q()
.
- Returns:
The list of expected queries.
- Return type:
- get_review_requests_from_user_equeries(*, from_user: Union[str, User], distinct: bool = False, **kwargs: Unpack[_AccessibleKwargs]) ExpectedQueries [source]¶
Return queries for review requests from a user.
This corresponds to a call from
ReviewRequest.objects.from_user()
.New in version 5.0.7.
- Parameters:
from_user (
str
ordjango.contrib.auth.models.User
) – The username or user that review requests would be published from for the query.distinct (
bool
, optional) – Whether this is a distinct query.**kwargs (
dict
, optional) – Keyword arguments to pass toget_review_requests_accessible_q()
.
- Returns:
The list of expected queries.
- Return type:
- get_review_requests_to_group_equeries(*, to_group_name: str, distinct: bool = False, **kwargs: Unpack[_AccessibleKwargs]) ExpectedQueries [source]¶
Return queries for review requests to a group.
This corresponds to a call from
ReviewRequest.objects.to_group()
.New in version 5.0.7.
- Parameters:
to_group (
str
) – The name of the group that review requests would be assigned to.distinct (
bool
, optional) – Whether this is a distinct query.**kwargs (
dict
, optional) – Keyword arguments to pass toget_review_requests_accessible_q()
.
- Returns:
The list of expected queries.
- Return type:
- get_review_requests_to_user_equeries(*, to_user: Union[str, User], to_user_profile: Optional[Profile] = None, target_groups: Sequence[Group] = [], distinct: bool = False, **kwargs: Unpack[_AccessibleKwargs]) ExpectedQueries [source]¶
Return queries for review requests to a user.
This corresponds to a call from
ReviewRequest.objects.to_user()
.New in version 5.0.7.
- Parameters:
to_user (
str
ordjango.contrib.auth.models.User
) – The username or user that review requests would be assigned to.to_user_profile (
reviewboard.accounts.models.Profile
) – The profile of the user that review requests would be assigned to.target_groups (
list
ofreviewboard.reviews.models.group.Group
) – The list of review groups that the user may be a member of, for the query.distinct (
bool
, optional) – Whether this is a distinct query.**kwargs (
dict
, optional) – Keyword arguments to pass toget_review_requests_accessible_q()
.
- Returns:
The list of expected queries.
- Return type:
- get_review_requests_to_user_directly_equeries(*, to_user: Union[str, User], to_user_profile: Optional[Profile] = None, distinct: bool = False, **kwargs: Unpack[_AccessibleKwargs]) ExpectedQueries [source]¶
Return queries for review requests directly to a user.
This corresponds to a call from
ReviewRequest.objects.to_user_directly()
.New in version 5.0.7.
- Parameters:
to_user (
str
ordjango.contrib.auth.models.User
) – The username or user that review requests would be assigned to.to_user_profile (
reviewboard.accounts.models.Profile
) – The profile of the user that review requests would be assigned to.target_groups (
list
ofreviewboard.reviews.models.group.Group
) – The list of review groups that the user may be a member of, for the query.distinct (
bool
, optional) – Whether this is a distinct query.**kwargs (
dict
, optional) – Keyword arguments to pass toget_review_requests_accessible_q()
.
- Returns:
The list of expected queries.
- Return type:
- get_review_requests_to_user_groups_equeries(*, to_user: Union[str, User], to_user_profile: Optional[Profile] = None, target_groups: Sequence[Group] = [], distinct: bool = False, **kwargs: Unpack[_AccessibleKwargs]) ExpectedQueries [source]¶
Return queries for review requests to a user’s groups.
This corresponds to a call from
ReviewRequest.objects.to_user_groups()
.New in version 5.0.7.
- Parameters:
to_user (
str
ordjango.contrib.auth.models.User
) – The username or user belonging to a group that review requests would be assigned to.to_user_profile (
reviewboard.accounts.models.Profile
) – The profile of the user belonging to a group that review requests would be assigned to.target_groups (
list
ofreviewboard.reviews.models.group.Group
) – The list of review groups that the user may be a member of, for the query.distinct (
bool
, optional) – Whether this is a distinct query.**kwargs (
dict
, optional) – Keyword arguments to pass toget_review_requests_accessible_q()
.
- Returns:
The list of expected queries.
- Return type:
- get_review_requests_to_or_from_user_equeries(*, to_or_from_user: Union[str, User], to_or_from_user_profile: Optional[Profile] = None, target_groups: Sequence[Group] = [], distinct: bool = False, **kwargs: Unpack[_AccessibleKwargs]) ExpectedQueries [source]¶
Return queries for review requests to/from a user.
This corresponds to a call from
ReviewRequest.objects.to_user()
.New in version 5.0.7.
- Parameters:
to_or_from_user (
str
ordjango.contrib.auth.models.User
) – The username or user that review requests would be assigned to or posted from.to_or_from_user_profile (
reviewboard.accounts.models.Profile
) – The profile of the user that review requests would be assigned to or posted from.target_groups (
list
ofreviewboard.reviews.models.group.Group
) – The list of review groups that the user may be a member of, for the query.distinct (
bool
, optional) – Whether this is a distinct query.**kwargs (
dict
, optional) – Keyword arguments to pass toget_review_requests_accessible_q()
.
- Returns:
The list of expected queries.
- Return type: