예제 #1
0
 def test_loads(self):
     commit = Commit.loads(_COMMIT_DATA)
     assert commit.commit_id == _COMMIT_DATA["commitId"]
     assert commit.title == _COMMIT_DATA["title"]
     assert commit.description == _COMMIT_DATA["description"]
     assert commit.committer == User.loads(_COMMIT_DATA["committer"])
     assert commit.parent_commit_id == _COMMIT_DATA["parentCommitId"]
예제 #2
0
 def test_init(self):
     user = User.loads(_USER_DATA)
     commit = Commit(_COMMIT_ID, _PARENT_COMMIT_ID, _TITLE, _DESCRIPTION, user)
     assert commit.commit_id == _COMMIT_ID
     assert commit.title == _TITLE
     assert commit.description == _DESCRIPTION
     assert commit.committer == user
     assert commit.parent_commit_id == _PARENT_COMMIT_ID
예제 #3
0
    def _generate_commits(
        self, revision: str, offset: int = 0, limit: int = 128
    ) -> Generator[Commit, None, int]:
        params: Dict[str, Any] = {"offset": offset, "limit": limit, "commit": revision}

        response = self._client.open_api_do(
            "GET", "commits", self._dataset_id, params=params
        ).json()

        for item in response["commits"]:
            yield Commit.loads(item)

        return response["totalCount"]  # type: ignore[no-any-return]
예제 #4
0
 def test_dumps(self):
     user = User.loads(_USER_DATA)
     commit = Commit(_COMMIT_ID, _PARENT_COMMIT_ID, _TITLE, _DESCRIPTION, user)
     assert commit.dumps() == _COMMIT_DATA