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

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

```diff
@@            Coverage Diff             @@
##           master     #207      +/-   ##
==========================================
+ Coverage   91.48%   91.56%   +0.08%     
==========================================
  Files          19       19              
  Lines        1303     1304       +1     
  Branches      231      231              
==========================================
+ Hits         1192     1194       +2     
  Misses         90       90              
+ Partials       21       20       -1
```


| [Impacted Files](https://codecov.io/gh/repobee/repobee/pull/207?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [repobee/gitlab\_api.py](https://codecov.io/gh/repobee/repobee/pull/207/diff?src=pr&el=tree#diff-cmVwb2JlZS9naXRsYWJfYXBpLnB5) | `81.57% <100%> (+1.04%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/repobee/repobee/pull/207?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/207?src=pr&el=footer). Last update [56406c9...0aaf811](https://codecov.io/gh/repobee/repobee/pull/207?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

diff --git a/repobee/gitlab_api.py b/repobee/gitlab_api.py
index 66e43e4..6038109 100644
--- a/repobee/gitlab_api.py
+++ b/repobee/gitlab_api.py
@@ -294,7 +294,8 @@ class GitLabAPI(apimeta.API):
         Returns:
             a list of urls corresponding to the repo names.
         """
-        group_url = "{}/{}".format(self._base_url, self._group_name)
+        group_name = org_name if org_name else self._group_name
+        group_url = "{}/{}".format(self._base_url, group_name)
         repo_urls = (
             [
                 "{}/{}.git".format(group_url, repo_name)

GitLabAPI.get_repo_urls ignores org_name argument
It always uses the target group's name, but supplying org_name should override it. This becomes problematic when trying to clone master repos from a master group that is separate from the target group (as is recommended).
diff --git a/tests/test_gitlab_api.py b/tests/test_gitlab_api.py
index 545c735..de395b1 100644
--- a/tests/test_gitlab_api.py
+++ b/tests/test_gitlab_api.py
@@ -332,15 +332,93 @@ class TestEnsureTeamsAndMembers:
                 assert not group.members.list()
 
 
+@pytest.fixture
+def master_repo_names():
+    return ["task-1", "task-2", "task-3"]
+
+
+class TestGetRepoUrls:
+    def test_get_master_repo_urls(self, master_repo_names):
+        """When supplied with only master_repo_names, get_repo_urls should
+        return urls for those master repos, expecting them to be in the target
+        group.
+        """
+        # arrange
+        api = repobee.gitlab_api.GitLabAPI(BASE_URL, TOKEN, TARGET_GROUP)
+        expected_urls = [
+            api._insert_auth("{}/{}/{}.git".format(BASE_URL, TARGET_GROUP, mn))
+            for mn in master_repo_names
+        ]
+        assert (
+            expected_urls
+        ), "there must be at least some urls for this test to make sense"
+
+        # act
+        actual_urls = api.get_repo_urls(master_repo_names)
+
+        # assert
+        assert sorted(actual_urls) == sorted(expected_urls)
+
+    def test_get_master_repo_urls_in_master_group(self, master_repo_names):
+        """When supplied with master_repo_names and org_name, the urls
+        generated should go to the group named org_name instead of the default
+        target group.
+        """
+        # arrange
+        master_group = "master-" + TARGET_GROUP  # guaranteed != TARGET_GROUP
+        api = repobee.gitlab_api.GitLabAPI(BASE_URL, TOKEN, TARGET_GROUP)
+        expected_urls = [
+            api._insert_auth("{}/{}/{}.git".format(BASE_URL, master_group, mn))
+            for mn in master_repo_names
+        ]
+        assert (
+            expected_urls
+        ), "there must be at least some urls for this test to make sense"
+
+        # act
+        actual_urls = api.get_repo_urls(
+            master_repo_names, org_name=master_group
+        )
+
+        # assert
+        assert sorted(actual_urls) == sorted(expected_urls)
+
+    def test_get_student_repo_urls(self, master_repo_names):
+        """When supplied with the students argument, the generated urls should
+        go to the student repos related to the supplied master repos.
+        """
+        # arrange
+        api = repobee.gitlab_api.GitLabAPI(BASE_URL, TOKEN, TARGET_GROUP)
+        expected_urls = [
+            api._insert_auth(
+                "{}/{}/{}/{}.git".format(
+                    BASE_URL,
+                    TARGET_GROUP,
+                    str(student_group),
+                    repobee.util.generate_repo_name(str(student_group), mn),
+                )
+            )
+            for student_group in constants.STUDENTS
+            for mn in master_repo_names
+        ]
+        assert (
+            expected_urls
+        ), "there must be at least some urls for this test to make sense"
+
+        # act
+        actual_urls = api.get_repo_urls(
+            master_repo_names, students=constants.STUDENTS
+        )
+
+        # assert
+        assert sorted(actual_urls) == sorted(expected_urls)
+
+
 class TestCreateRepos:
     @pytest.fixture
     def api(self, api_mock):
         yield repobee.gitlab_api.GitLabAPI(BASE_URL, TOKEN, TARGET_GROUP)
 
-    @pytest.fixture
-    def master_repo_names(self):
-        return ["task-1", "task-2", "task-3"]
-
     @pytest.fixture
     def repos(self, api, master_repo_names):
         """Setup repo tuples along with groups for the repos to be created

pip install -e .
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-mock codecov
apt-get update apt-get install -y gcc
3.6
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
appdirs==1.4.4
attrs==22.2.0
certifi==2021.5.30
cffi==1.15.1
charset-normalizer==2.0.12
codecov==2.1.13
colored==1.4.4
coverage==6.2
daiquiri==3.2.1
Deprecated==1.2.18
idna==3.10
importlib-metadata==4.8.3
iniconfig==1.1.1
packaging==21.3
pluggy==1.0.0
py==1.11.0
pycparser==2.21
PyGithub==1.56
PyJWT==2.4.0
PyNaCl==1.5.0
pyparsing==3.1.4
pytest==7.0.1
pytest-cov==4.0.0
pytest-mock==3.6.1
python-gitlab==1.8.0
python-json-logger==2.0.7
-e git+https://github.com/repobee/repobee.git@56406c954267f04b1cd53b9fd36bb98a5fbc299a#egg=repobee
repobee-plug==0.5.1
requests==2.27.1
six==1.17.0
tomli==1.2.3
typing_extensions==4.1.1
urllib3==1.26.20
wrapt==1.16.0
zipp==3.6.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=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - 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=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - appdirs==1.4.4
      - attrs==22.2.0
      - cffi==1.15.1
      - charset-normalizer==2.0.12
      - codecov==2.1.13
      - colored==1.4.4
      - coverage==6.2
      - daiquiri==3.2.1
      - deprecated==1.2.18
      - idna==3.10
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - packaging==21.3
      - pluggy==1.0.0
      - py==1.11.0
      - pycparser==2.21
      - pygithub==1.56
      - pyjwt==2.4.0
      - pynacl==1.5.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytest-cov==4.0.0
      - pytest-mock==3.6.1
      - python-gitlab==1.8.0
      - python-json-logger==2.0.7
      - repobee-plug==0.5.1
      - requests==2.27.1
      - six==1.17.0
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - wrapt==1.16.0
      - zipp==3.6.0
prefix: /opt/conda/envs/repobee

tests/test_gitlab_api.py::TestGetRepoUrls::test_get_master_repo_urls_in_master_group
tests/test_gitlab_api.py::TestEnsureTeamsAndMembers::test_with_no_pre_existing_groups tests/test_gitlab_api.py::TestEnsureTeamsAndMembers::test_with_multi_student_groups tests/test_gitlab_api.py::TestEnsureTeamsAndMembers::test_run_twice tests/test_gitlab_api.py::TestGetRepoUrls::test_get_master_repo_urls tests/test_gitlab_api.py::TestGetRepoUrls::test_get_student_repo_urls tests/test_gitlab_api.py::TestCreateRepos::test_run_once_for_valid_repos tests/test_gitlab_api.py::TestCreateRepos::test_run_twice_for_valid_repos
repobee/gitlab_api.py
repobee/gitlab_api.py