repobee_testhelpers
Module Reference¶
Module reference for the RepoBee testhelpers.
This package is not yet entirely stable, so expect that there may be (minor) breaking changes across releases.
fixtures¶
funcs¶
Helper functions for tests.
-
repobee_testhelpers.funcs.
get_api
(platform_url, org_name='fall2020', user='ric', token='123token456')[source]¶ Return an instance of the
fakeapi.FakeAPI
, configured for the tests.- Return type
-
repobee_testhelpers.funcs.
get_repos
(platform_url, org_name='fall2020')[source]¶ Get all repos from the given platform and organization.
-
repobee_testhelpers.funcs.
get_student_teams
(platform_url, org_name='fall2020')[source]¶ Like
get_platform_teams()
, but converts each team to aStudentTeam
. for easier comparison.- Parameters
- Return type
- Returns
A list of student teams.
-
repobee_testhelpers.funcs.
get_teams
(platform_url, org_name='fall2020')[source]¶ Get all of the teams from the given platform and organization. Note that this returns the actual platform implementation of
Team
.
-
repobee_testhelpers.funcs.
initialize_repo
(path, default_branch='master')[source]¶ Initialize the directory to a Git repo and commit all files in it.
-
repobee_testhelpers.funcs.
run_repobee
(cmd, **kwargs)[source]¶ Helper function to call
repobee.run
when using thefakeapi.FakeAPI
platform API.This function will by default use a config file that sets appropriate values for
students_file
,user
,org_name
andtemplate_org_name
for use with theFakeAPI
platform API. If you wish to use a different config, simply passconfig_file="/path/to/your/config"
to the function, orconfig_file=""
to not use a config file at all.The
FakeAPI
plugin is always loaded last, so it is the not possible to use another platform API with this function. If you wish to do so, you should use :py:class`repobee.run` directly instead.
-
repobee_testhelpers.funcs.
tree_hash
(repo_root)[source]¶ Get the hash of the HEAD tree object of this repository.
const¶
Constants for use in tests.
localapi¶
A local implementation of the repobee_plug.PlatformAPI
specification that can be used to test RepoBee and plugins.
Danger
This module is in alpha version, and its behavior may change without notice.
-
class
repobee_testhelpers.localapi.
Issue
(title, body, number, created_at, author, state, assignees)[source]¶
-
class
repobee_testhelpers.localapi.
LocalAPI
(base_url, org_name, user, token)[source]¶ A local implementation of the
repobee_plug.PlatformAPI
specification, which emulates a GitHub-like platform without accessing any network resources.-
assign_members
(team, members, permission=<TeamPermission.PUSH: 'push'>)[source]¶ See
repobee_plug.PlatformAPI.assign_members()
.- Return type
-
assign_repo
(team, repo, permission)[source]¶ See
repobee_plug.PlatformAPI.assign_repo()
.- Return type
-
create_issue
(title, body, repo, assignees=None)[source]¶ See
repobee_plug.PlatformAPI.create_issue()
.- Return type
-
create_repo
(name, description, private, team=None)[source]¶ See
repobee_plug.PlatformAPI.create_repo()
.- Return type
-
create_team
(name, members=None, permission=<TeamPermission.PUSH: 'push'>)[source]¶ See
repobee_plug.PlatformAPI.create_team()
.- Return type
-
get_repo_urls
(assignment_names, org_name=None, team_names=None, insert_auth=False)[source]¶ Get repo urls for all specified repo names in the organization. As checking if every single repo actually exists takes a long time with a typical REST API, this function does not in general guarantee that the urls returned actually correspond to existing repos.
If the
org_name
argument is supplied, urls are computed relative to that organization. If it is not supplied, the target organization is used.If the teams argument is supplied, student repo urls are computed instead of master repo urls.
- Parameters
- Return type
- Returns
a list of urls corresponding to the repo names.
-
static
verify_settings
(user, org_name, base_url, token, template_org_name=None)[source]¶ Verify the following (to the extent that is possible and makes sense for the specific platform):
Base url is correct
The token has sufficient access privileges
- Target organization (specifiend by
org_name
) exists If template_org_name is supplied, this is also checked to exist.
- Target organization (specifiend by
- User is owner in organization (verify by getting
If template_org_name is supplied, user is also checked to be an owner of it.
organization member list and checking roles)
Should raise an appropriate subclass of
PlatformError
when a problem is encountered.- Parameters
- Return type
- Returns
True if the connection is well formed.
- Raises
PlatformError –
-