Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
hughhhh committed Oct 6, 2022
1 parent 7cbc9a3 commit feafb35
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
1 change: 1 addition & 0 deletions superset/db_engine_specs/gsheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class GSheetsParametersType(TypedDict):

class GSheetsPropertiesType(TypedDict):
parameters: GSheetsParametersType
catalog: Dict[str, str]


class GSheetsEngineSpec(SqliteEngineSpec):
Expand Down
48 changes: 35 additions & 13 deletions tests/unit_tests/db_engine_specs/test_gsheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,29 @@ def test_validate_parameters_simple() -> None:
"parameters": {
"service_account_info": "",
"catalog": {},
}
},
"catalog": {},
}
errors = GSheetsEngineSpec.validate_parameters(properties)
assert errors == [
SupersetError(
message="Sheet name is required",
error_type=SupersetErrorType.CONNECTION_MISSING_PARAMETERS_ERROR,
level=ErrorLevel.WARNING,
extra={"catalog": {"idx": 0, "name": True}},
),
]


def test_validate_parameters_simple_with_in_root_catalog() -> None:
from superset.db_engine_specs.gsheets import (
GSheetsEngineSpec,
GSheetsPropertiesType,
)

properties: GSheetsPropertiesType = {
"properties": {},
"catalog": {},
}
errors = GSheetsEngineSpec.validate_parameters(properties)
assert errors == [
Expand Down Expand Up @@ -76,12 +98,12 @@ def test_validate_parameters_catalog(
properties: GSheetsPropertiesType = {
"parameters": {
"service_account_info": "",
"catalog": {
"private_sheet": "https://docs.google.com/spreadsheets/d/1/edit",
"public_sheet": "https://docs.google.com/spreadsheets/d/1/edit#gid=1",
"not_a_sheet": "https://www.google.com/",
},
}
},
"catalog": {
"private_sheet": "https://docs.google.com/spreadsheets/d/1/edit",
"public_sheet": "https://docs.google.com/spreadsheets/d/1/edit#gid=1",
"not_a_sheet": "https://www.google.com/",
},
}
errors = GSheetsEngineSpec.validate_parameters(properties) # ignore: type

Expand Down Expand Up @@ -168,12 +190,12 @@ def test_validate_parameters_catalog_and_credentials(
properties: GSheetsPropertiesType = {
"parameters": {
"service_account_info": "",
"catalog": {
"private_sheet": "https://docs.google.com/spreadsheets/d/1/edit",
"public_sheet": "https://docs.google.com/spreadsheets/d/1/edit#gid=1",
"not_a_sheet": "https://www.google.com/",
},
}
},
"catalog": {
"private_sheet": "https://docs.google.com/spreadsheets/d/1/edit",
"public_sheet": "https://docs.google.com/spreadsheets/d/1/edit#gid=1",
"not_a_sheet": "https://www.google.com/",
},
}
errors = GSheetsEngineSpec.validate_parameters(properties) # ignore: type
assert errors == [
Expand Down

0 comments on commit feafb35

Please sign in to comment.