Skip to content

Commit 6b1dfc3

Browse files
committed
source-microsoft-sharepoint: ruff format
1 parent 919b5a3 commit 6b1dfc3

File tree

2 files changed

+44
-26
lines changed

2 files changed

+44
-26
lines changed

airbyte-integrations/connectors/source-microsoft-sharepoint/source_microsoft_sharepoint/stream_reader.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,7 @@ def get_files(url: str, path: str) -> Iterable[MicrosoftSharePointRemoteFile]:
199199
last_modified = datetime.strptime(child["lastModifiedDateTime"], "%Y-%m-%dT%H:%M:%SZ")
200200
created_at = datetime.strptime(child["createdDateTime"], "%Y-%m-%dT%H:%M:%SZ")
201201
yield MicrosoftSharePointRemoteFile(
202-
uri=new_path,
203-
download_url=child["@microsoft.graph.downloadUrl"],
204-
last_modified=last_modified,
205-
created_at=created_at
202+
uri=new_path, download_url=child["@microsoft.graph.downloadUrl"], last_modified=last_modified, created_at=created_at
206203
)
207204
else: # Object is a folder, retrieve children
208205
child_url = f"{base_url}/items/{child['id']}/children" # Use item endpoint for nested objects
@@ -226,10 +223,7 @@ def get_files(url: str, path: str) -> Iterable[MicrosoftSharePointRemoteFile]:
226223
last_modified = datetime.strptime(item_data["lastModifiedDateTime"], "%Y-%m-%dT%H:%M:%SZ")
227224
created_at = datetime.strptime(item_data["createdDateTime"], "%Y-%m-%dT%H:%M:%SZ")
228225
yield MicrosoftSharePointRemoteFile(
229-
uri=new_path,
230-
download_url=item_data["@microsoft.graph.downloadUrl"],
231-
last_modified=last_modified,
232-
created_at=created_at
226+
uri=new_path, download_url=item_data["@microsoft.graph.downloadUrl"], last_modified=last_modified, created_at=created_at
233227
)
234228
else:
235229
# Initial object is a folder, start file retrieval
@@ -246,7 +240,7 @@ def _list_directories_and_files(self, root_folder, path) -> Iterable[MicrosoftSh
246240
uri=item_path,
247241
download_url=item.properties["@microsoft.graph.downloadUrl"],
248242
last_modified=item.properties["lastModifiedDateTime"],
249-
created_at=item.properties["createdDateTime"]
243+
created_at=item.properties["createdDateTime"],
250244
)
251245
else:
252246
yield from self._list_directories_and_files(item, item_path)

airbyte-integrations/connectors/source-microsoft-sharepoint/unit_tests/test_stream_reader.py

+41-17
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@
3030

3131
def create_mock_drive_item(is_file, name, children=None):
3232
"""Helper function to create a mock drive item."""
33-
mock_item = MagicMock(properties={
34-
"@microsoft.graph.downloadUrl": "test_url",
35-
"lastModifiedDateTime": datetime(1991, 8, 24),
36-
"createdDateTime": datetime(1991, 8, 24),
37-
})
33+
mock_item = MagicMock(
34+
properties={
35+
"@microsoft.graph.downloadUrl": "test_url",
36+
"lastModifiedDateTime": datetime(1991, 8, 24),
37+
"createdDateTime": datetime(1991, 8, 24),
38+
}
39+
)
3840
mock_item.is_file = is_file
3941
mock_item.name = name
4042
mock_item.children.get.return_value.execute_query = Mock(return_value=children or [])
@@ -70,13 +72,13 @@ def create_mock_drive_files():
7072
uri="file1.csv",
7173
download_url="https://example.com/file1.csv",
7274
last_modified=datetime(2021, 1, 1),
73-
created_at=datetime(2021, 1, 1)
75+
created_at=datetime(2021, 1, 1),
7476
),
7577
MicrosoftSharePointRemoteFile(
7678
uri="file2.txt",
7779
download_url="https://example.com/file2.txt",
7880
last_modified=datetime(2021, 1, 1),
79-
created_at=datetime(2021, 1, 1)
81+
created_at=datetime(2021, 1, 1),
8082
),
8183
]
8284

@@ -91,13 +93,13 @@ def create_mock_shared_drive_files():
9193
uri="file3.csv",
9294
download_url="https://example.com/file3.csv",
9395
last_modified=datetime(2021, 3, 1),
94-
created_at=datetime(2021, 3, 1)
96+
created_at=datetime(2021, 3, 1),
9597
),
9698
MicrosoftSharePointRemoteFile(
9799
uri="file4.txt",
98100
download_url="https://example.com/file4.txt",
99101
last_modified=datetime(2021, 4, 1),
100-
created_at=datetime(2021, 4, 1)
102+
created_at=datetime(2021, 4, 1),
101103
),
102104
]
103105

@@ -406,10 +408,20 @@ def test_list_directories_and_files():
406408

407409
assert len(result) == 2
408410
assert result == [
409-
MicrosoftSharePointRemoteFile(uri='https://example.com/root/folder1/file1.txt', last_modified=datetime(1991, 8, 24, 0, 0),
410-
mime_type=None, download_url='test_url', created_at=datetime(1991, 8, 24, 0, 0)),
411-
MicrosoftSharePointRemoteFile(uri='https://example.com/root/file2.txt', last_modified=datetime(1991, 8, 24, 0, 0),
412-
mime_type=None, download_url='test_url', created_at=datetime(1991, 8, 24, 0, 0)),
411+
MicrosoftSharePointRemoteFile(
412+
uri="https://example.com/root/folder1/file1.txt",
413+
last_modified=datetime(1991, 8, 24, 0, 0),
414+
mime_type=None,
415+
download_url="test_url",
416+
created_at=datetime(1991, 8, 24, 0, 0),
417+
),
418+
MicrosoftSharePointRemoteFile(
419+
uri="https://example.com/root/file2.txt",
420+
last_modified=datetime(1991, 8, 24, 0, 0),
421+
mime_type=None,
422+
download_url="test_url",
423+
created_at=datetime(1991, 8, 24, 0, 0),
424+
),
413425
]
414426

415427

@@ -507,7 +519,7 @@ def test_get_shared_files_from_all_drives(
507519
"name": "TestFile.txt",
508520
"@microsoft.graph.downloadUrl": "http://example.com/download",
509521
"lastModifiedDateTime": "2021-01-01T00:00:00Z",
510-
"createdDateTime": "2021-01-01T00:00:00Z"
522+
"createdDateTime": "2021-01-01T00:00:00Z",
511523
}
512524

513525
empty_folder_response = {"folder": True, "value": []}
@@ -532,7 +544,7 @@ def test_get_shared_files_from_all_drives(
532544
"name": "NestedFile.txt",
533545
"@microsoft.graph.downloadUrl": "http://example.com/nested",
534546
"lastModifiedDateTime": "2021-01-02T00:00:00Z",
535-
"createdDateTime": "2021-01-02T00:00:00Z"
547+
"createdDateTime": "2021-01-02T00:00:00Z",
536548
}
537549
],
538550
"name": "subfolder2",
@@ -547,7 +559,13 @@ def test_get_shared_files_from_all_drives(
547559
file_response,
548560
[],
549561
[
550-
MicrosoftSharePointRemoteFile(uri='http://example.com/TestFile.txt', last_modified=datetime(2021, 1, 1, 0, 0), mime_type=None, download_url='http://example.com/download', created_at=datetime(2021, 1, 1, 0, 0)),
562+
MicrosoftSharePointRemoteFile(
563+
uri="http://example.com/TestFile.txt",
564+
last_modified=datetime(2021, 1, 1, 0, 0),
565+
mime_type=None,
566+
download_url="http://example.com/download",
567+
created_at=datetime(2021, 1, 1, 0, 0),
568+
),
551569
],
552570
False,
553571
None,
@@ -564,7 +582,13 @@ def test_get_shared_files_from_all_drives(
564582
not_empty_subfolder_response,
565583
],
566584
[
567-
MicrosoftSharePointRemoteFile(uri='http://example.com/subfolder2/NestedFile.txt', last_modified=datetime(2021, 1, 2, 0, 0), mime_type=None, download_url='http://example.com/nested', created_at=datetime(2021, 1, 2, 0, 0))
585+
MicrosoftSharePointRemoteFile(
586+
uri="http://example.com/subfolder2/NestedFile.txt",
587+
last_modified=datetime(2021, 1, 2, 0, 0),
588+
mime_type=None,
589+
download_url="http://example.com/nested",
590+
created_at=datetime(2021, 1, 2, 0, 0),
591+
)
568592
],
569593
False,
570594
None,

0 commit comments

Comments
 (0)