Skip to content

Commit 83c62a7

Browse files
author
Ilyas Gasanov
committed
[DOP-21442] Add Excel API schema
1 parent 84542a9 commit 83c62a7

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

syncmaster/schemas/v1/transfers/file_format.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class CSV(BaseModel):
1818
encoding: str = "utf-8"
1919
quote: str = '"'
2020
escape: str = "\\"
21-
header: bool = False
21+
include_header: bool = False
2222
line_sep: str = "\n"
2323

2424

@@ -36,5 +36,5 @@ class JSON(BaseModel):
3636

3737
class Excel(BaseModel):
3838
type: EXCEL_FORMAT
39-
include_header: bool
39+
include_header: bool = False
4040
start_cell: str | None = None

tests/resources/file_df_connection/generate_files.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ def _to_string(obj):
103103
return obj
104104

105105

106-
def _write_csv(data: list[dict], file: TextIO, header: bool = False, **kwargs) -> None:
106+
def _write_csv(data: list[dict], file: TextIO, include_header: bool = False, **kwargs) -> None:
107107
columns = list(data[0].keys())
108108
writer = csv.DictWriter(file, fieldnames=columns, lineterminator="\n", **kwargs)
109109

110-
if header:
110+
if include_header:
111111
writer.writeheader()
112112

113113
for row in data:
@@ -123,7 +123,7 @@ def save_as_csv_without_header(data: list[dict], path: Path) -> None:
123123
def save_as_csv_with_header(data: list[dict], path: Path) -> None:
124124
path.mkdir(parents=True, exist_ok=True)
125125
with open(path / "file.csv", "w", newline="") as file:
126-
_write_csv(data, file, header=True)
126+
_write_csv(data, file, include_header=True)
127127

128128

129129
def save_as_csv_with_delimiter(data: list[dict], path: Path) -> None:
@@ -403,12 +403,12 @@ def save_as_xlsx(data: list[dict], path: Path) -> None:
403403
shutil.rmtree(root, ignore_errors=True)
404404
root.mkdir(parents=True, exist_ok=True)
405405

406-
save_as_xlsx_with_options(data, root / "without_header", header=False)
407-
save_as_xlsx_with_options(data, root / "with_header", header=True)
406+
save_as_xlsx_with_options(data, root / "without_header", include_header=False)
407+
save_as_xlsx_with_options(data, root / "with_header", include_header=True)
408408
save_as_xlsx_with_options(
409409
data,
410410
root / "with_data_address",
411-
header=False,
411+
include_header=False,
412412
sheet_name="ABC",
413413
startcol=10,
414414
startrow=5,
@@ -420,12 +420,12 @@ def save_as_xls(data: list[dict], path: Path) -> None:
420420
shutil.rmtree(root, ignore_errors=True)
421421
root.mkdir(parents=True, exist_ok=True)
422422

423-
save_as_xls_with_options(data, root / "without_header", header=False)
424-
save_as_xls_with_options(data, root / "with_header", header=True)
423+
save_as_xls_with_options(data, root / "without_header", include_header=False)
424+
save_as_xls_with_options(data, root / "with_header", include_header=True)
425425
save_as_xls_with_options(
426426
data,
427427
root / "with_data_address",
428-
header=False,
428+
include_header=False,
429429
sheet_name="ABC",
430430
startcol=10,
431431
startrow=5,

tests/test_integration/test_run_transfer/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ def source_file_format(request: FixtureRequest):
515515
if name == "csv":
516516
return "csv", CSV(
517517
lineSep="\n",
518-
header=True,
518+
include_header=True,
519519
**params,
520520
)
521521

@@ -542,7 +542,7 @@ def target_file_format(request: FixtureRequest):
542542
if name == "csv":
543543
return "csv", CSV(
544544
lineSep="\n",
545-
header=True,
545+
include_header=True,
546546
timestampFormat="yyyy-MM-dd'T'HH:mm:ss.SSSSSS+00:00",
547547
**params,
548548
)

tests/test_unit/test_transfers/test_file_transfers/test_create_transfer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"encoding": "utf-8",
3333
"quote": '"',
3434
"escape": "\\",
35-
"header": False,
35+
"include_header": False,
3636
"line_sep": "\n",
3737
},
3838
"options": {
@@ -119,7 +119,7 @@ async def test_developer_plus_can_create_s3_transfer(
119119
"encoding": "utf-8",
120120
"quote": '"',
121121
"escape": "\\",
122-
"header": False,
122+
"include_header": False,
123123
"line_sep": "\n",
124124
},
125125
"excel": {
@@ -234,7 +234,7 @@ async def test_developer_plus_can_create_hdfs_transfer(
234234
"encoding": "utf-8",
235235
"quote": '"',
236236
"escape": "\\",
237-
"header": False,
237+
"include_header": False,
238238
"line_sep": "\n",
239239
},
240240
"excel": {

tests/test_unit/test_transfers/test_file_transfers/test_read_transfer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"delimiter": ",",
1717
"encoding": "utf-8",
1818
"escape": "\\",
19-
"header": False,
19+
"include_header": False,
2020
"line_sep": "\n",
2121
"quote": '"',
2222
"type": "csv",

tests/test_unit/test_transfers/test_file_transfers/test_update_transfer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"delimiter": ",",
1717
"encoding": "utf-8",
1818
"escape": "\\",
19-
"header": False,
19+
"include_header": False,
2020
"line_sep": "\n",
2121
"quote": '"',
2222
"type": "csv",

tests/test_unit/test_transfers/transfer_fixtures/transfers_fixture.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async def group_transfers(
5757
"delimiter": ",",
5858
"encoding": "utf-8",
5959
"escape": "\\",
60-
"header": False,
60+
"include_header": False,
6161
"line_sep": "\n",
6262
"quote": '"',
6363
"type": "csv",

0 commit comments

Comments
 (0)