codecov-io: # [Codecov](https://codecov.io/gh/repobee/repobee/pull/201?src=pr&el=h1) Report
> Merging [#201](https://codecov.io/gh/repobee/repobee/pull/201?src=pr&el=desc) into [master](https://codecov.io/gh/repobee/repobee/commit/771ab4e3b32ee13edf575b442f27f7c840db2dff?src=pr&el=desc) will **decrease** coverage by `0.16%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/repobee/repobee/pull/201/graphs/tree.svg?width=650&token=5vOKgkphZe&height=150&src=pr)](https://codecov.io/gh/repobee/repobee/pull/201?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #201      +/-   ##
==========================================
- Coverage   92.89%   92.73%   -0.17%     
==========================================
  Files          18       18              
  Lines        1182     1183       +1     
  Branches      203      203              
==========================================
- Hits         1098     1097       -1     
- Misses         68       70       +2     
  Partials       16       16
```


| [Impacted Files](https://codecov.io/gh/repobee/repobee/pull/201?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [repobee/github\_api.py](https://codecov.io/gh/repobee/repobee/pull/201/diff?src=pr&el=tree#diff-cmVwb2JlZS9naXRodWJfYXBpLnB5) | `92.4% <100%> (+0.03%)` | :arrow_up: |
| [repobee/cli.py](https://codecov.io/gh/repobee/repobee/pull/201/diff?src=pr&el=tree#diff-cmVwb2JlZS9jbGkucHk=) | `97.4% <0%> (-0.87%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/repobee/repobee/pull/201?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/repobee/repobee/pull/201?src=pr&el=footer). Last update [771ab4e...c1c9346](https://codecov.io/gh/repobee/repobee/pull/201?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

diff --git a/repobee/github_api.py b/repobee/github_api.py
index 5a698af..a1d4585 100644
--- a/repobee/github_api.py
+++ b/repobee/github_api.py
@@ -21,6 +21,7 @@ import github
 from repobee import exception
 from repobee import tuples
 from repobee import util
+from repobee import apimeta
 
 REQUIRED_OAUTH_SCOPES = {"admin:org", "repo"}
 
@@ -95,7 +96,7 @@ def _try_api_request(ignore_statuses: Optional[Iterable[int]] = None):
         )
 
 
-class GitHubAPI:
+class GitHubAPI(apimeta.API):
     """A highly specialized GitHub API class for repobee. The API is
     affiliated both with an organization, and with the whole GitHub
     instance. Almost all operations take place on the target
@@ -136,7 +137,7 @@ class GitHubAPI:
     def token(self):
         return self._token
 
-    def get_teams_in(
+    def _get_teams_in(
         self, team_names: Iterable[str]
     ) -> Generator[github.Team.Team, None, None]:
         """Get all teams that match any team name in the team_names iterable.
@@ -163,7 +164,7 @@ class GitHubAPI:
             team_names: A list of team names for teams to be deleted.
         """
         deleted = set()  # only for logging
-        for team in self.get_teams_in(team_names):
+        for team in self._get_teams_in(team_names):
             team.delete()
             deleted.add(team.name)
             LOGGER.info("deleted team {}".format(team.name))
@@ -220,7 +221,7 @@ class GitHubAPI:
         for team in [team for team in teams if member_lists[team.name]]:
             self._ensure_members_in_team(team, member_lists[team.name])
 
-        return list(self.get_teams_in(set(member_lists.keys())))
+        return list(self._get_teams_in(set(member_lists.keys())))
 
     def _ensure_teams_exist(
         self, team_names: Iterable[str], permission: str = "push"
@@ -280,9 +281,9 @@ class GitHubAPI:
                     ", ".join(existing_members), team.name
                 )
             )
-        self.add_to_team(missing_members, team)
+        self._add_to_team(missing_members, team)
 
-    def add_to_team(self, members: Iterable[str], team: github.Team.Team):
+    def _add_to_team(self, members: Iterable[str], team: github.Team.Team):
         """Add members to a team.
 
         Args:
@@ -294,18 +295,18 @@ class GitHubAPI:
             for user in users:
                 team.add_membership(user)
 
-    def create_repos(self, repo_infos: Iterable[tuples.Repo]):
+    def create_repos(self, repos: Iterable[tuples.Repo]):
         """Create repositories in the given organization according to the Repos.
         Repos that already exist are skipped.
 
         Args:
-            repo_infos: An iterable of Repo namedtuples.
+            repos: An iterable of Repo namedtuples.
 
         Returns:
             A list of urls to all repos corresponding to the Repos.
         """
         repo_urls = []
-        for info in repo_infos:
+        for info in repos:
             created = False
             with _try_api_request(ignore_statuses=[422]):
                 kwargs = dict(
@@ -489,7 +490,7 @@ class GitHubAPI:
             issue: An an optional Issue tuple to override the default issue.
         """
         issue = issue or DEFAULT_REVIEW_ISSUE
-        for team, repo in self.add_repos_to_teams(team_to_repos):
+        for team, repo in self._add_repos_to_teams(team_to_repos):
             # TODO team.get_members() api request is a bit redundant, it
             # can be solved in a more efficient way by passing in the
             # allocations
@@ -527,7 +528,7 @@ class GitHubAPI:
             assigned_repos is a :py:class:`~repobee.tuples.Review`.
         """
         reviews = collections.defaultdict(list)
-        teams = self.get_teams_in(review_team_names)
+        teams = self._get_teams_in(review_team_names)
         for team in teams:
             with _try_api_request():
                 LOGGER.info("processing {}".format(team.name))
@@ -557,7 +558,7 @@ class GitHubAPI:
 
         return reviews
 
-    def add_repos_to_teams(
+    def _add_repos_to_teams(
         self, team_to_repos: Mapping[str, Iterable[str]]
     ) -> Generator[
         Tuple[github.Team.Team, github.Repository.Repository], None, None

Adapt github_api.GitHubAPI to make use of the apimeta.API class
diff --git a/tests/test_github_api.py b/tests/test_github_api.py
index f03a05a..9976d19 100644
--- a/tests/test_github_api.py
+++ b/tests/test_github_api.py
@@ -668,7 +668,7 @@ class TestGetIssues:
 
 @pytest.fixture
 def team_to_repos(api, no_repos, organization):
-    """Create a team_to_repos mapping for use in add_repos_to_teams, anc create
+    """Create a team_to_repos mapping for use in _add_repos_to_teams, anc create
     each team and repo. Return the team_to_repos mapping.
     """
     num_teams = 10
@@ -718,7 +718,7 @@ class TestAddReposToTeams:
         expected_tups = sorted(team_to_repos.items())
 
         # act
-        result = list(api.add_repos_to_teams(team_to_repos))
+        result = list(api._add_repos_to_teams(team_to_repos))
         result.sort(key=lambda tup: tup[0].name)
 
         # assert

pip install -e .
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-mock
apt-get update apt-get install -y gcc
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
appdirs==1.4.4
certifi @ file:///croot/certifi_1671487769961/work/certifi
cffi==1.15.1
charset-normalizer==3.4.1
colored==1.4.4
coverage==7.2.7
cryptography==44.0.2
daiquiri==3.2.1
Deprecated==1.2.18
exceptiongroup==1.2.2
idna==3.10
importlib-metadata==6.7.0
iniconfig==2.0.0
packaging==24.0
pluggy==1.2.0
pycparser==2.21
PyGithub==2.3.0
PyJWT==2.8.0
PyNaCl==1.5.0
pytest==7.4.4
pytest-cov==4.1.0
pytest-mock==3.11.1
python-json-logger==3.0.1
-e git+https://github.com/repobee/repobee.git@771ab4e3b32ee13edf575b442f27f7c840db2dff#egg=repobee
repobee-plug==0.5.1
requests==2.31.0
tomli==2.0.1
typing_extensions==4.7.1
urllib3==2.0.7
wrapt==1.16.0
zipp==3.15.0

name: repobee
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - appdirs==1.4.4
      - cffi==1.15.1
      - charset-normalizer==3.4.1
      - colored==1.4.4
      - coverage==7.2.7
      - cryptography==44.0.2
      - daiquiri==3.2.1
      - deprecated==1.2.18
      - exceptiongroup==1.2.2
      - idna==3.10
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - packaging==24.0
      - pluggy==1.2.0
      - pycparser==2.21
      - pygithub==2.3.0
      - pyjwt==2.8.0
      - pynacl==1.5.0
      - pytest==7.4.4
      - pytest-cov==4.1.0
      - pytest-mock==3.11.1
      - python-json-logger==3.0.1
      - repobee==1.3.3
      - repobee-plug==0.5.1
      - requests==2.31.0
      - tomli==2.0.1
      - typing-extensions==4.7.1
      - urllib3==2.0.7
      - wrapt==1.16.0
      - zipp==3.15.0
prefix: /opt/conda/envs/repobee

tests/test_github_api.py::TestAddReposToTeams::test_happy_path
tests/test_github_api.py::TestEnsureTeamsAndMembers::test_no_previous_teams tests/test_github_api.py::TestEnsureTeamsAndMembers::test_all_teams_exist_but_without_members tests/test_github_api.py::TestEnsureTeamsAndMembers::test_raises_on_non_422_exception[unexpected_exc0] tests/test_github_api.py::TestEnsureTeamsAndMembers::test_raises_on_non_422_exception[unexpected_exc1] tests/test_github_api.py::TestEnsureTeamsAndMembers::test_raises_on_non_422_exception[unexpected_exc2] tests/test_github_api.py::TestEnsureTeamsAndMembers::test_running_twice_has_no_ill_effects tests/test_github_api.py::TestCreateRepos::test_creates_correct_repos tests/test_github_api.py::TestCreateRepos::test_skips_existing_repos tests/test_github_api.py::TestCreateRepos::test_raises_on_unexpected_error[unexpected_exception0] tests/test_github_api.py::TestCreateRepos::test_raises_on_unexpected_error[unexpected_exception1] tests/test_github_api.py::TestCreateRepos::test_raises_on_unexpected_error[unexpected_exception2] tests/test_github_api.py::TestCreateRepos::test_returns_all_urls tests/test_github_api.py::TestCreateRepos::test_create_repos_without_team_id tests/test_github_api.py::TestGetRepoUrls::test_with_token_without_user tests/test_github_api.py::TestGetRepoUrls::test_with_token_and_user tests/test_github_api.py::TestGetRepoUrls::test_with_students tests/test_github_api.py::TestOpenIssue::test_on_existing_repos tests/test_github_api.py::TestOpenIssue::test_on_some_non_existing_repos tests/test_github_api.py::TestOpenIssue::test_no_crash_when_no_repos_are_found tests/test_github_api.py::TestCloseIssue::test_closes_correct_issues tests/test_github_api.py::TestCloseIssue::test_no_crash_if_no_repos_found tests/test_github_api.py::TestCloseIssue::test_no_crash_if_no_issues_found tests/test_github_api.py::TestGetIssues::test_get_all_open_issues tests/test_github_api.py::TestGetIssues::test_get_all_closed_issues tests/test_github_api.py::TestGetIssues::test_get_issues_when_one_repo_doesnt_exist tests/test_github_api.py::TestGetIssues::test_get_open_issues_by_regex tests/test_github_api.py::TestAddReposToReviewTeams::test_with_default_issue tests/test_github_api.py::TestDeleteTeams::test_delete_non_existing_teams_does_not_crash tests/test_github_api.py::TestDeleteTeams::test_delete_existing_teams tests/test_github_api.py::TestVerifySettings::test_happy_path tests/test_github_api.py::TestVerifySettings::test_empty_token_raises_bad_credentials tests/test_github_api.py::TestVerifySettings::test_incorrect_info_raises_not_found_error[get_user] tests/test_github_api.py::TestVerifySettings::test_incorrect_info_raises_not_found_error[get_organization] tests/test_github_api.py::TestVerifySettings::test_bad_token_scope_raises tests/test_github_api.py::TestVerifySettings::test_not_owner_raises tests/test_github_api.py::TestVerifySettings::test_raises_unexpected_exception_on_unexpected_status tests/test_github_api.py::TestVerifySettings::test_none_user_raises tests/test_github_api.py::TestVerifySettings::test_mismatching_user_login_raises tests/test_github_api.py::TestGetPeerReviewProgress::test_nothing_returns tests/test_github_api.py::TestGetPeerReviewProgress::test_with_review_teams_but_no_repos
repobee/github_api.py
repobee/github_api.py