Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloud API Normalization #438

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions lean/components/api/file_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,20 @@ def get_all(self, project_id: int) -> List[QCFullFile]:

return [QCFullFile(**file) for file in data["files"]]

def create(self, project_id: int, file_name: str, content: str) -> QCMinimalFile:
def create(self, project_id: int, file_name: str, content: str) -> None:
"""Creates a new file.

:param project_id: the id of the project to create a file for
:param file_name: the name of the file to create
:param content: the content of the file to create
:return: the created file
"""
data = self._api.post("files/create", {
"projectId": project_id,
"name": file_name,
"content": content
})

return QCMinimalFile(**data["files"][0])

def update(self, project_id: int, file_name: str, content: str) -> QCMinimalFile:
def update(self, project_id: int, file_name: str, content: str) -> None:
"""Updates an existing file.

:param project_id: the id of the project to update a file in
Expand All @@ -82,8 +79,6 @@ def update(self, project_id: int, file_name: str, content: str) -> QCMinimalFile
"content": content
})

return QCMinimalFile(**data["files"][0])

def delete(self, project_id: int, file_name: str) -> None:
"""Deletes an existing file.

Expand Down
7 changes: 3 additions & 4 deletions lean/models/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ class ProjectEncryptionKey(WrappedBaseModel):
name: str

class QCCollaborator(WrappedBaseModel):
id: int
uid: int
blivecontrol: bool
epermission: str
profileimage: str
liveControl: bool
permission: str
profileImage: str
name: str
owner: bool = False

Expand Down
5 changes: 1 addition & 4 deletions tests/components/api/test_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,7 @@ def test_files_crud() -> None:

with create_project(api_client, "Test Project") as project:
# Test a file can be created
created_file = file_client.create(project.projectId, "file.py", "# This is a comment")

assert created_file.name == "file.py"
assert created_file.content == "# This is a comment"
file_client.create(project.projectId, "file.py", "# This is a comment")

# Test the file can be retrieved
retrieved_file = file_client.get(project.projectId, "file.py")
Expand Down
Loading