Skip to content

Commit debc880

Browse files
refactor: address PR comments
1 parent 898ac8c commit debc880

File tree

5 files changed

+31
-40
lines changed

5 files changed

+31
-40
lines changed

nisystemlink/clients/file/_file_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ def get_files(
148148

149149
@post("service-groups/Default/query-files-linq")
150150
def query_files_linq(
151-
self, query: models.LinqFileQueryRequest
152-
) -> models.LinqFileQueryResponse:
153-
"""Queries files using LINQ syntax.
151+
self, query: models.FileLinqQueryRequest
152+
) -> models.FileLinqQueryResponse:
153+
"""Queries file using LINQ filters.
154154
155155
Args:
156156
query: The LINQ query request containing the query string and optional parameters.

nisystemlink/clients/file/models/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
from ._link import Link
55
from ._operations import V1Operations
66
from ._update_metadata import UpdateMetadataRequest
7-
from ._linq_file_query import LinqFileQueryRequest, LinqFileQueryResponse
7+
from ._file_linq_query import FileLinqQueryRequest, FileLinqQueryResponse
88

99
# flake8: noqa

nisystemlink/clients/file/models/_linq_file_query.py renamed to nisystemlink/clients/file/models/_file_linq_query.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from typing import List, Optional
22

33
from nisystemlink.clients.core._uplink._json_model import JsonModel
4-
from nisystemlink.clients.file.models._file_metadata import LinqFileMetadata
4+
from nisystemlink.clients.file.models._file_metadata import FileLinqQueryMetadata
55
from nisystemlink.clients.file.models._file_query_order_by import FileLinqQueryOrderBy
66

77

8-
class LinqFileQueryRequest(JsonModel):
8+
class FileLinqQueryRequest(JsonModel):
99
filter: Optional[str] = None
1010
"""
1111
The filter criteria for files. Consists of a string of queries composed using AND/OR operators.
@@ -15,11 +15,11 @@ class LinqFileQueryRequest(JsonModel):
1515
Example Filter syntax: '[property name][operator][operand] and [property name][operator][operand]'
1616
"""
1717

18-
ordery_by: Optional[FileLinqQueryOrderBy] = None
18+
order_by: Optional[FileLinqQueryOrderBy] = None
1919
"""The property by which to order the files in the response."""
2020

2121
order_by_descending: Optional[bool] = False
22-
"""If true, the files are ordered in descending order based on the property specified in `ordery_by`."""
22+
"""If true, the files are ordered in descending order based on the property specified in `order_by`."""
2323

2424
take: Optional[int] = None
2525
"""The maximum number of files to return in the response. Default value is 1000"""
@@ -45,8 +45,8 @@ class TotalCount(JsonModel):
4545
"""Describes the number of files that were returned as a result of the query in the database"""
4646

4747

48-
class LinqFileQueryResponse(JsonModel):
49-
available_files: List[LinqFileMetadata]
48+
class FileLinqQueryResponse(JsonModel):
49+
available_files: List[FileLinqQueryMetadata]
5050
"""The list of files returned by the query"""
5151

5252
total_count: TotalCount

nisystemlink/clients/file/models/_file_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class FileMetadata(BaseFileMetadata):
8585
"""
8686

8787

88-
class LinqFileMetadata(BaseFileMetadata):
88+
class FileLinqQueryMetadata(BaseFileMetadata):
8989
"""Metadata for a file returned by a LINQ query."""
9090

9191
updated: Optional[datetime] = None

tests/integration/file/test_file_client.py

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pytest # type: ignore
99
from nisystemlink.clients.core import ApiException
1010
from nisystemlink.clients.file import FileClient
11-
from nisystemlink.clients.file.models import LinqFileQueryRequest, UpdateMetadataRequest
11+
from nisystemlink.clients.file.models import FileLinqQueryRequest, UpdateMetadataRequest
1212
from nisystemlink.clients.file.utilities import rename_file
1313

1414
FILE_NOT_FOUND_ERR = "Not Found"
@@ -209,47 +209,38 @@ def test__back_off_retry__works(self, client: FileClient, test_file):
209209
def test__query_files_linq__filter_by_name_succeeds(
210210
self, client: FileClient, test_file, random_filename_extension: str
211211
):
212-
"""Test LINQ query filtering by file name."""
213-
# Upload the test file with random name
214212
file_id = test_file(file_name=random_filename_extension, cleanup=False)
215213

216-
try:
217-
# Query by exact name match
218-
query_request = LinqFileQueryRequest(
219-
filter=f'name == "{random_filename_extension}"'
220-
)
221-
response = client.query_files_linq(query=query_request)
222-
223-
assert response.available_files is not None
224-
assert len(response.available_files) == 1
225-
assert response.available_files[0].id == file_id
226-
assert response.available_files[0].properties is not None
227-
assert (
228-
response.available_files[0].properties["Name"]
229-
== random_filename_extension
230-
)
231-
assert response.total_count.value == 1
232-
assert response.total_count.relation == "eq"
233-
234-
finally:
235-
client.delete_file(id=file_id)
214+
query_request = FileLinqQueryRequest(
215+
filter=f'name == "{random_filename_extension}"'
216+
)
217+
response = client.query_files_linq(query=query_request)
218+
219+
assert response.available_files is not None
220+
assert len(response.available_files) == 1
221+
assert response.available_files[0].id == file_id
222+
assert response.available_files[0].properties is not None
223+
assert (
224+
response.available_files[0].properties["Name"]
225+
== random_filename_extension
226+
)
227+
assert response.total_count.value == 1
228+
assert response.total_count.relation == "eq"
229+
230+
client.delete_file(id=file_id)
236231

237232
def test__query_files_linq__invalid_filter_raises(self, client: FileClient):
238-
"""Test LINQ query with invalid filter syntax raises exception."""
239-
# Query with malformed filter
240-
query_request = LinqFileQueryRequest(filter="invalid filter syntax:")
233+
query_request = FileLinqQueryRequest(filter="invalid filter syntax:")
241234

242235
with pytest.raises(ApiException):
243236
client.query_files_linq(query=query_request)
244237

245238
def test__query_files_linq__filter_returns_no_results(self, client: FileClient):
246-
"""Test LINQ query with valid filter that matches no files."""
247-
# Query with a filter that should match no existing files
248239
unique_nonexistent_name = (
249240
f"{PREFIX}nonexistent_file_{randint(100000, 999999)}.random_extension"
250241
)
251242

252-
query_request = LinqFileQueryRequest(
243+
query_request = FileLinqQueryRequest(
253244
filter=f'name == "{unique_nonexistent_name}"'
254245
)
255246
response = client.query_files_linq(query=query_request)

0 commit comments

Comments
 (0)