示例#1
0
 def to_plug_repo(self) -> plug.Repo:
     return plug.Repo(
         name=self.name,
         description=self.description,
         private=self.private,
         url=self.url,
         implementation=self,
     )
示例#2
0
文件: gitea.py 项目: repobee/repobee
 def _wrap_repo(self, repo_data: dict) -> plug.Repo:
     return plug.Repo(
         name=repo_data["name"],
         description=repo_data["description"],
         private=repo_data["private"],
         url=repo_data["clone_url"],
         implementation=repo_data,
     )
示例#3
0
 def _wrap_project(self, project) -> plug.Repo:
     with _try_api_request():
         return plug.Repo(
             name=project.path,
             description=project.description,
             private=project.visibility == "private",
             url=project.attributes["http_url_to_repo"],
             implementation=project,
         )
示例#4
0
文件: github.py 项目: repobee/repobee
 def _wrap_repo(self, repo: _Repo) -> plug.Repo:
     with _try_api_request():
         return plug.Repo(
             name=repo.name,
             description=repo.description,
             private=repo.private,
             url=repo.html_url,
             implementation=repo,
         )
示例#5
0
    def test_fetches_all_issues(self, happy_github, api):
        impl_mock = MagicMock(spec=github.Repository.Repository)
        repo = plug.Repo(
            name="name",
            description="descr",
            private=True,
            url="bla",
            implementation=impl_mock,
        )

        api.get_repo_issues(repo)

        impl_mock.get_issues.assert_called_once_with(state="all")
示例#6
0
    def test_delete_repo(self, api):
        platform_repo = MagicMock()
        repo = plug.Repo(
            "some-repo",
            "Some description",
            True,
            "url-doesnt-matter",
            implementation=platform_repo,
        )

        api.delete_repo(repo)

        platform_repo.delete.assert_called_once()
示例#7
0
    def test_delete_repo_calls_correct_function(self):
        # arrange
        platform_repo_mock = unittest.mock.MagicMock()
        repo = plug.Repo(
            name="some-repo",
            description="a repo",
            private=True,
            url="doesntmatter",
            implementation=platform_repo_mock,
        )
        api = _repobee.ext.gitlab.GitLabAPI(BASE_URL, TOKEN, TARGET_GROUP)

        # act
        api.delete_repo(repo)

        # assert
        platform_repo_mock.delete.assert_called_once()
示例#8
0
    def test_sets_assignees_defaults_to_notset(self, happy_github, api):
        """Assert that ``assignees = None`` is replaced with ``NotSet``."""
        impl_mock = MagicMock(spec=github.Repository.Repository)
        repo = plug.Repo(
            name="name",
            description="descr",
            private=True,
            url="bla",
            implementation=impl_mock,
        )

        with patch("_repobee.ext.defaults.github.GitHubAPI._wrap_issue",
                   autospec=True):
            api.create_issue("Title", "Body", repo)

        impl_mock.create_issue.assert_called_once_with(
            "Title", body="Body", assignees=github.GithubObject.NotSet)
示例#9
0
文件: gitea.py 项目: repobee/repobee
    def create_repo(
        self,
        name: str,
        description: str,
        private: bool,
        team: Optional[plug.Team] = None,
    ) -> plug.Repo:
        """See :py:meth:`repobee_plug.PlatformAPI.create_repo`."""
        endpoint = f"/orgs/{self._org_name}/repos"
        data = dict(
            name=name,
            description=description,
            auto_init=False,
            private=private,
            default_branch="master",
        )
        response = self._request(requests.post, endpoint, data=data)

        if response.status_code == 409:
            raise plug.PlatformError(
                f"repository {self._org_name}/{name} already exists",
                status=response.status_code,
            )

        resp_data = response.json()
        repo = plug.Repo(
            name=name,
            description=description,
            private=private,
            url=resp_data["clone_url"],
            implementation=resp_data,
        )

        if team:
            self.assign_repo(team, repo, plug.TeamPermission.PUSH)

        return repo