Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rjambrecic committed Jun 26, 2024
1 parent ce16353 commit da707bf
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 8 deletions.
6 changes: 3 additions & 3 deletions google_sheets/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ async def get_sheet(
spreadsheet_id: Annotated[
str, Query(description="ID of the Google Sheet to fetch data from")
],
range: Annotated[
title: Annotated[
str,
Query(description="The range of cells to fetch data from. E.g. 'Sheet1!A1:B2'"),
Query(description="The title of the sheet to fetch data from"),
],
) -> Union[str, List[List[str]]]:
service = await build_service(user_id=user_id, service_name="sheets", version="v4")
values = await get_sheet_f(
service=service, spreadsheet_id=spreadsheet_id, range=range
service=service, spreadsheet_id=spreadsheet_id, range=title
)

if not values:
Expand Down
65 changes: 60 additions & 5 deletions tests/app/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_get_sheet(self) -> None:
"google_sheets.app.get_sheet_f", return_value=excepted
) as mock_get_sheet:
response = client.get(
"/get-sheet?user_id=123&spreadsheet_id=abc&range=Sheet1"
"/get-sheet?user_id=123&spreadsheet_id=abc&title=Sheet1"
)
mock_load_user_credentials.assert_called_once()
mock_get_sheet.assert_called_once()
Expand Down Expand Up @@ -308,15 +308,15 @@ def test_openapi(self) -> None:
"description": "ID of the Google Sheet to fetch data from",
},
{
"name": "range",
"name": "title",
"in": "query",
"required": True,
"schema": {
"type": "string",
"description": "The range of cells to fetch data from. E.g. 'Sheet1!A1:B2'",
"title": "Range",
"description": "The title of the sheet to fetch data from",
"title": "Title",
},
"description": "The range of cells to fetch data from. E.g. 'Sheet1!A1:B2'",
"description": "The title of the sheet to fetch data from",
},
],
"responses": {
Expand Down Expand Up @@ -523,6 +523,61 @@ def test_openapi(self) -> None:
},
}
},
"/get-all-sheet-titles": {
"get": {
"summary": "Get All Sheet Titles",
"description": "Get all sheet titles within a Google Spreadsheet",
"operationId": "get_all_sheet_titles_get_all_sheet_titles_get",
"parameters": [
{
"name": "user_id",
"in": "query",
"required": True,
"schema": {
"type": "integer",
"description": "The user ID for which the data is requested",
"title": "User Id",
},
"description": "The user ID for which the data is requested",
},
{
"name": "spreadsheet_id",
"in": "query",
"required": True,
"schema": {
"type": "string",
"description": "ID of the Google Sheet to fetch data from",
"title": "Spreadsheet Id",
},
"description": "ID of the Google Sheet to fetch data from",
},
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {"type": "string"},
"title": "Response Get All Sheet Titles Get All Sheet Titles Get",
}
}
},
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
},
},
},
}
},
},
"components": {
"schemas": {
Expand Down

0 comments on commit da707bf

Please sign in to comment.