Add test for from_dict
This commit is contained in:
Родитель
26e4348ded
Коммит
ab6269e176
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Dict, Iterator, List, Optional
|
from typing import Any, Dict, Iterator, List, Optional
|
||||||
|
|
||||||
from .view import View
|
from .view import View, ViewDict
|
||||||
|
|
||||||
|
|
||||||
class FunnelAnalysisView(View):
|
class FunnelAnalysisView(View):
|
||||||
|
@ -56,6 +56,13 @@ class FunnelAnalysisView(View):
|
||||||
[tables],
|
[tables],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(
|
||||||
|
klass, namespace: str, name: str, _dict: ViewDict
|
||||||
|
) -> FunnelAnalysisView:
|
||||||
|
"""Get a FunnalAnalysisView from a dict representation."""
|
||||||
|
return FunnelAnalysisView(namespace, _dict["tables"])
|
||||||
|
|
||||||
def to_lookml(self, bq_client, v1_name: Optional[str]) -> Dict[str, Any]:
|
def to_lookml(self, bq_client, v1_name: Optional[str]) -> Dict[str, Any]:
|
||||||
"""Get this view as LookML."""
|
"""Get this view as LookML."""
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -58,6 +58,26 @@ def test_view_from_db_views(funnel_analysis_view):
|
||||||
assert actual == funnel_analysis_view
|
assert actual == funnel_analysis_view
|
||||||
|
|
||||||
|
|
||||||
|
def test_view_from_dict(funnel_analysis_view):
|
||||||
|
actual = FunnelAnalysisView.from_dict(
|
||||||
|
"glean_app",
|
||||||
|
"funnel_analysis",
|
||||||
|
{
|
||||||
|
"type": "funnel_analysis_view",
|
||||||
|
"tables": [
|
||||||
|
{
|
||||||
|
"funnel_analysis": "events_daily_table",
|
||||||
|
"event_types": "`mozdata.glean_app.event_types`",
|
||||||
|
"event_type_1": "event_types",
|
||||||
|
"event_type_2": "event_types",
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
assert actual == funnel_analysis_view
|
||||||
|
|
||||||
|
|
||||||
def test_explore_from_views(funnel_analysis_view):
|
def test_explore_from_views(funnel_analysis_view):
|
||||||
expected = FunnelAnalysisExplore(
|
expected = FunnelAnalysisExplore(
|
||||||
"funnel_analysis", {"base_view": "funnel_analysis"}
|
"funnel_analysis", {"base_view": "funnel_analysis"}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче