reviewboard.testing.hosting_services¶
- class TestServiceForm(*args, hosting_service_cls: Type[BaseHostingService], **kwargs)[source]¶
Bases:
BaseHostingServiceRepositoryForm
- __annotations__ = {}¶
- declared_fields = {'test_repo_name': <django.forms.fields.CharField object>}¶
- class TestService(account: HostingServiceAccount)[source]¶
Bases:
BaseHostingService
- hosting_service_id: Optional[str] = 'test'[source]¶
The unique ID of the hosting service.
This should be lowercase, and only consist of the characters a-z, 0-9,
_
, and-
.New in version 3.0.16: This should now be set on all custom hosting services. It will be required in Review Board 4.0.
- Type:
- name: Optional[StrOrPromise] = 'Test Service'[source]¶
The display name for the hosting service.
- Type:
- form[source]¶
alias of
TestServiceForm
- needs_authorization: bool = True[source]¶
Whether usage of this hosting service requires authorization.
This value can also be set within
repository_plans
.- Type:
- supports_repositories: bool = True[source]¶
Whether this service supports source code repositories.
This should be set to
True
if the service provides a compatible source code repository and the subclass implements all of the following methods:get_file()
get_file_exists()
get_repository_fields()
Several other optional methods may also be defined and used if this is set.
- Type:
- supports_bug_trackers: bool = True[source]¶
Whether this service supports bug trackers.
This should be set to
True
if the service provides its own bug tracker and the subclass implements all of the following methods:get_bug_tracker_field()
get_bug_tracker_requires_username()
- Type:
- supports_two_factor_auth: bool = True[source]¶
Whether this service supports two-factor authentication.
This should be set to
True
if the service supports two-factor authentication when communicating with the API and the service implements support inauthorize()
.- Type:
- has_repository_hook_instructions: bool = True[source]¶
Whether this service provides repository hook instructions.
This should be set to
True
if the subclass implements instructions’ on configuring useful repository hooks in the following method:get_repository_hook_instructions()
- Type:
- supported_scmtools: List[str] = ['Git', 'Test', 'perforce'][source]¶
A list of SCMTools IDs or names that are supported by this service.
This should contain a list of SCMTool IDs that this service can work with. For backwards-compatibility, it may instead contain a list of SCMTool names (corresponding to database registration names).
This may also be specified per-plan in the
plans
.Changed in version 3.0.16: Added support for SCMTool IDs. A future version will deprecate using SCMTool names here.
- visible_scmtools: Optional[List[str]] = ['git', 'test'][source]¶
A list of SCMTool IDs that are visible when configuring the service.
This should contain a list of SCMTool IDs that this service will show when configuring a repository. It can be used to offer continued legacy support for an SCMTool without offering it when creating new repositories. If not specified, all SCMTools listed in
supported_scmtools
are assumed to be visible.If explicitly set, this should always be equal to or a subset of
supported_scmtools
.This may also be specified per-plan in the
plans
.New in version 3.0.17.
- bug_tracker_field: Optional[str] = 'http://example.com/%(hosting_account_username)s/%(test_repo_name)s/issue/%%s'[source]¶
A templated value for the bug tracker field.
The value will be filled in based on the cleaned bug tracker form data. It must take templated keys in the form of
%(key_name)s
.- Type:
- repository_fields: SCMToRepositoryFields = {'Git': {'path': 'http://example.com/%(test_repo_name)s/'}, 'Perforce': {'path': '%(test_repo_name).p4.example.com:1666'}, 'Test': {'path': 'http://example.com/%(test_repo_name)s/'}}[source]¶
Templated values to set for model repository fields.
Each key corresponds to a SCMTool ID or name, and each value to a mapping of model attribute names to templates for values to populate based on cleaned repository form data. It must take templated keys in the form of
%(key_name)s
.- Type:
- authorize(username, password, hosting_url, local_site_name=None, two_factor_auth_code=None, *args, **kwargs)[source]¶
Authorize an account for the hosting service.
- Parameters:
username (
str
) – The username for the account.password (
str
) – The password for the account.hosting_url (
str
) – The hosting URL for the service, if self-hosted.credentials (
dict
) –All credentials provided by the authentication form.
This will contain the username, password, and anything else provided by that form.
two_factor_auth_code (
str
, optional) – The two-factor authentication code provided by the user.local_site_name (
str
, optional) – The Local Site name, if any, that the account should be bound to.*args (
tuple
) – Extra unused positional arguments.**kwargs (
dict
) – Extra keyword arguments containing values from the repository’s configuration.
- Raises:
reviewboard.hostingsvcs.errors.AuthorizationError – The credentials provided were not valid.
reviewboard.hostingsvcs.errors.TwoFactorAuthCodeRequiredError – A two-factor authentication code is required to authorize this account. The request must be retried with the same credentials and with the
two_factor_auth_code
parameter provided.
- is_authorized()[source]¶
Return whether or not the account is currently authorized.
An account may no longer be authorized if the hosting service switches to a new API that doesn’t match the current authorization records. This function will determine whether the account is still considered authorized.
- Returns:
Whether or not the associated account is authorized.
- Return type:
- check_repository(test_repo_name, *args, **kwargs)[source]¶
Checks the validity of a repository configuration.
This performs a check against the hosting service or repository to ensure that the information provided by the user represents a valid repository.
This is passed in the repository details, such as the path and raw credentials, as well as the SCMTool class being used, the LocalSite’s name (if any), and all field data from the HostingServiceForm as keyword arguments.
- Parameters:
path (
str
) – The repository URL.username (
str
) – The username to use.password (
str
) – The password to use.scmtool_class (
type
) – The subclass ofSCMTool
that should be used.local_site_name (
unicode
) – The name of the local site associated with the repository, orNone
.*args (
tuple
) – Additional positional arguments, unique to each hosting service.**kwargs (
dict
) – Additional keyword arguments, unique to each hosting service.
- Raises:
reviewboard.hostingsvcs.errors.RepositoryError – The repository is not valid.
- __annotations__ = {'auth_form': 'Optional[Type[BaseHostingServiceAuthForm]]', 'bug_tracker_field': 'Optional[str]', 'client': 'HostingServiceClient', 'client_class': 'Type[HostingServiceClient]', 'form': 'Optional[Type[BaseHostingServiceRepositoryForm]]', 'has_repository_hook_instructions': 'bool', 'hosting_service_id': 'Optional[str]', 'name': 'Optional[StrOrPromise]', 'needs_authorization': 'bool', 'plans': 'Optional[Sequence[Tuple[str, HostingServicePlan]]]', 'repository_fields': 'SCMToRepositoryFields', 'repository_url_patterns': 'Optional[List[_AnyURL]]', 'self_hosted': 'bool', 'supported_scmtools': 'List[str]', 'supports_bug_trackers': 'bool', 'supports_list_remote_repositories': 'bool', 'supports_post_commit': 'bool', 'supports_repositories': 'bool', 'supports_ssh_key_association': 'bool', 'supports_two_factor_auth': 'bool', 'visible': 'bool', 'visible_scmtools': 'Optional[List[str]]'}¶
- class SelfHostedTestService(account: HostingServiceAccount)[source]¶
Bases:
TestService
- hosting_service_id: Optional[str] = 'self_hosted_test'[source]¶
The unique ID of the hosting service.
This should be lowercase, and only consist of the characters a-z, 0-9,
_
, and-
.New in version 3.0.16: This should now be set on all custom hosting services. It will be required in Review Board 4.0.
- Type:
- name: Optional[StrOrPromise] = 'Self-Hosted Test'[source]¶
The display name for the hosting service.
- Type:
- self_hosted: bool = True[source]¶
Whether this service can be self-hosted.
This should be set to
True
if the service can be hosted at a custom URL.- Type:
- bug_tracker_field: Optional[str] = '%(hosting_url)s/%(test_repo_name)s/issue/%%s'[source]¶
A templated value for the bug tracker field.
The value will be filled in based on the cleaned bug tracker form data. It must take templated keys in the form of
%(key_name)s
.- Type:
- repository_fields: SCMToRepositoryFields = {'Git': {'mirror_path': 'git@%(hosting_domain)s:%(test_repo_name)s/', 'path': '%(hosting_url)s/%(test_repo_name)s/'}, 'Test': {'mirror_path': 'git@%(hosting_domain)s:%(test_repo_name)s/', 'path': '%(hosting_url)s/%(test_repo_name)s/'}}[source]¶
Templated values to set for model repository fields.
Each key corresponds to a SCMTool ID or name, and each value to a mapping of model attribute names to templates for values to populate based on cleaned repository form data. It must take templated keys in the form of
%(key_name)s
.- Type:
- __annotations__ = {'auth_form': 'Optional[Type[BaseHostingServiceAuthForm]]', 'bug_tracker_field': 'Optional[str]', 'client': 'HostingServiceClient', 'client_class': 'Type[HostingServiceClient]', 'form': 'Optional[Type[BaseHostingServiceRepositoryForm]]', 'has_repository_hook_instructions': 'bool', 'hosting_service_id': 'Optional[str]', 'name': 'Optional[StrOrPromise]', 'needs_authorization': 'bool', 'plans': 'Optional[Sequence[Tuple[str, HostingServicePlan]]]', 'repository_fields': 'SCMToRepositoryFields', 'repository_url_patterns': 'Optional[List[_AnyURL]]', 'self_hosted': 'bool', 'supported_scmtools': 'List[str]', 'supports_bug_trackers': 'bool', 'supports_list_remote_repositories': 'bool', 'supports_post_commit': 'bool', 'supports_repositories': 'bool', 'supports_ssh_key_association': 'bool', 'supports_two_factor_auth': 'bool', 'visible': 'bool', 'visible_scmtools': 'Optional[List[str]]'}¶