Skip to content
Open
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
1 change: 1 addition & 0 deletions packages/gooddata-sdk/src/gooddata_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
ExportCustomOverride,
ExportRequest,
ExportSettings,
GrandTotalsPosition,
SlidesExportRequest,
VisualExportRequest,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# (C) 2023 GoodData Corporation
from typing import Literal
from typing import Literal, Optional

from attrs import define
from gooddata_api_client.model.custom_label import CustomLabel as ApiCustomLabel
Expand All @@ -12,6 +12,8 @@

from gooddata_sdk.catalog.base import Base

GrandTotalsPosition = Literal["pinnedBottom", "pinnedTop", "bottom", "top"]


@define(kw_only=True)
class ExportCustomLabel(Base):
Expand Down Expand Up @@ -46,6 +48,7 @@ def client_class() -> type[ApiCustomOverride]:
class ExportSettings(Base):
merge_headers: bool
show_filters: bool
grand_totals_position: Optional[GrandTotalsPosition] = None

@staticmethod
def client_class() -> type[ApiSettings]:
Expand Down
22 changes: 22 additions & 0 deletions packages/gooddata-sdk/tests/export/test_export_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
import os
from pathlib import Path

import pytest

from gooddata_sdk import (
Attribute,
ExecutionDefinition,
ExportCustomLabel,
ExportCustomMetric,
ExportCustomOverride,
ExportRequest,
ExportSettings,
GoodDataSdk,
GrandTotalsPosition,
ObjId,
SimpleMetric,
TableDimension,
Expand Down Expand Up @@ -89,6 +93,24 @@ def _tabular_by_visualization_id_base(test_config, export_format: str):
_validate_clean(goal_path)


@pytest.mark.parametrize(
"grand_totals_position",
[None, "pinnedBottom", "pinnedTop", "bottom", "top"],
)
def test_export_settings_grand_totals_position(grand_totals_position: GrandTotalsPosition):
settings = ExportSettings(
merge_headers=True,
show_filters=False,
grand_totals_position=grand_totals_position,
)
assert settings.grand_totals_position == grand_totals_position
snake_dict = settings._get_snake_dict()
if grand_totals_position is not None:
assert snake_dict["grand_totals_position"] == grand_totals_position
else:
assert "grand_totals_position" not in snake_dict


@gd_vcr.use_cassette(str(_fixtures_dir / "test_export_csv.yaml"))
def test_export_csv(test_config):
_tabular_export_base(test_config, "CSV")
Expand Down
Loading