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

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

```diff
@@            Coverage Diff             @@
##           master     #200      +/-   ##
==========================================
+ Coverage   92.87%   92.89%   +0.01%     
==========================================
  Files          18       18              
  Lines        1179     1182       +3     
  Branches      202      203       +1     
==========================================
+ Hits         1095     1098       +3     
  Misses         68       68              
  Partials       16       16
```


| [Impacted Files](https://codecov.io/gh/repobee/repobee/pull/200?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [repobee/github\_api.py](https://codecov.io/gh/repobee/repobee/pull/200/diff?src=pr&el=tree#diff-cmVwb2JlZS9naXRodWJfYXBpLnB5) | `92.37% <100%> (+0.09%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/repobee/repobee/pull/200?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/200?src=pr&el=footer). Last update [2af51ca...d8ac7c0](https://codecov.io/gh/repobee/repobee/pull/200?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 01e8353..5a698af 100644
--- a/repobee/github_api.py
+++ b/repobee/github_api.py
@@ -308,13 +308,13 @@ class GitHubAPI:
         for info in repo_infos:
             created = False
             with _try_api_request(ignore_statuses=[422]):
+                kwargs = dict(
+                    description=info.description, private=info.private
+                )
+                if info.team_id:  # using falsy results in an exception
+                    kwargs["team_id"] = info.team_id
                 repo_urls.append(
-                    self._org.create_repo(
-                        info.name,
-                        description=info.description,
-                        private=info.private,
-                        team_id=info.team_id,
-                    ).html_url
+                    self._org.create_repo(info.name, **kwargs).html_url
                 )
                 LOGGER.info("created {}/{}".format(self._org_name, info.name))
                 created = True

migrate does not work with GitHubAPI
#196 introduced a bug in the migrate command using the GitHubAPI class. `create_repos` expects `repo.team_id` to be not-none. If it is `None`, then the thing crashes. That is to say, if `repo.team_id` is `None` in `GitHubAPI.create_repos`, then it should not be passed on at all to the lower-level the `self._org.create_repo` call.
diff --git a/tests/test_github_api.py b/tests/test_github_api.py
index 5985226..f03a05a 100644
--- a/tests/test_github_api.py
+++ b/tests/test_github_api.py
@@ -438,6 +438,24 @@ class TestCreateRepos:
         for url in actual_urls:
             assert TOKEN in url
 
+    def test_create_repos_without_team_id(self, api):
+        """If there is no team id specified for the repo, then
+        github.Organization.create_repo must be called without the team_id
+        argument (because if it is called with team_id=None, there is a crash).
+        """
+        repo = tuples.Repo(
+            name="repo",
+            description="Some description",
+            private=True,
+            team_id=None,  # this is the important part!
+        )
+
+        api.create_repos([repo])
+
+        api._org.create_repo.assert_called_once_with(
+            repo.name, description=repo.description, private=repo.private
+        )
+
 
 class TestGetRepoUrls:
     """Tests for get_repo_urls."""

pip install -e .
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-mock codecov
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
codecov==2.1.13
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@2af51ca3028df5676d9a0cc56696666db03a9021#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
      - codecov==2.1.13
      - 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::TestCreateRepos::test_create_repos_without_team_id
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::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::TestAddReposToTeams::test_happy_path 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