Skip to content

Commit c1522f2

Browse files
authored
Merge pull request #456 from terminusdb/bugfix/eq-operator-list-issue
Bugfix/eq operator list issue
2 parents eee1db7 + 52647d9 commit c1522f2

File tree

2 files changed

+64
-19
lines changed

2 files changed

+64
-19
lines changed

terminusdb_client/tests/integration_tests/conftest.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ def is_local_server_running():
1313
"""Check if local TerminusDB server is running at http://127.0.0.1:6363"""
1414
try:
1515
response = requests.get("http://127.0.0.1:6363", timeout=2)
16-
# Server responds with 404 for root path, which means it's running
16+
# Server responds with 200 (success) or 404 (not found but server is up)
17+
# 401 (unauthorized) also indicates server is running but needs auth
1718
return response.status_code in [200, 404]
1819
except (requests.exceptions.ConnectionError, requests.exceptions.Timeout):
1920
return False
@@ -73,7 +74,9 @@ def docker_url_jwt(pytestconfig):
7374

7475
# Check if JWT server is already running (port 6367)
7576
if is_jwt_server_running():
76-
print("\n✓ Using existing JWT Docker TerminusDB server at http://127.0.0.1:6367")
77+
print(
78+
"\n✓ Using existing JWT Docker TerminusDB server at http://127.0.0.1:6367"
79+
)
7780
yield ("http://127.0.0.1:6367", jwt_token)
7881
return # Don't clean up - server was already running
7982

@@ -128,7 +131,9 @@ def docker_url_jwt(pytestconfig):
128131

129132
if seconds_waited > MAX_CONTAINER_STARTUP_TIME:
130133
clean_up_container()
131-
raise RuntimeError(f"JWT Container was too slow to startup (waited {MAX_CONTAINER_STARTUP_TIME}s)")
134+
raise RuntimeError(
135+
f"JWT Container was too slow to startup (waited {MAX_CONTAINER_STARTUP_TIME}s)"
136+
)
132137

133138
yield (test_url, jwt_token)
134139
clean_up_container()
@@ -145,9 +150,15 @@ def docker_url(pytestconfig):
145150
"""
146151
# Check if local test server is already running (port 6363)
147152
if is_local_server_running():
148-
print("\n✓ Using existing local TerminusDB test server at http://127.0.0.1:6363")
149-
print("⚠️ WARNING: Local server should be started with TERMINUSDB_AUTOLOGIN=true")
150-
print(" Or use: TERMINUSDB_SERVER_AUTOLOGIN=true ./tests/terminusdb-test-server.sh restart")
153+
print(
154+
"\n✓ Using existing local TerminusDB test server at http://127.0.0.1:6363"
155+
)
156+
print(
157+
"⚠️ WARNING: Local server should be started with TERMINUSDB_AUTOLOGIN=true"
158+
)
159+
print(
160+
" Or use: TERMINUSDB_SERVER_AUTOLOGIN=true ./tests/terminusdb-test-server.sh restart"
161+
)
151162
yield "http://127.0.0.1:6363"
152163
return # Don't clean up - server was already running
153164

@@ -200,7 +211,9 @@ def docker_url(pytestconfig):
200211
response = requests.get(test_url)
201212
# Server responds with 404 for root path, which means it's running
202213
assert response.status_code in [200, 404]
203-
print(f"✓ Docker container started successfully after {seconds_waited}s")
214+
print(
215+
f"✓ Docker container started successfully after {seconds_waited}s"
216+
)
204217
break
205218
except (requests.exceptions.ConnectionError, AssertionError):
206219
pass
@@ -210,7 +223,9 @@ def docker_url(pytestconfig):
210223

211224
if seconds_waited > MAX_CONTAINER_STARTUP_TIME:
212225
clean_up_container()
213-
raise RuntimeError(f"Container was too slow to startup (waited {MAX_CONTAINER_STARTUP_TIME}s)")
226+
raise RuntimeError(
227+
f"Container was too slow to startup (waited {MAX_CONTAINER_STARTUP_TIME}s)"
228+
)
214229

215230
yield test_url
216231
clean_up_container()

terminusdb_client/woqlquery/woql_query.py

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,8 @@ def _clean_object(self, user_obj, target=None):
411411
obj["node"] = user_obj
412412
elif type(user_obj) is list:
413413
elts = []
414-
for obj in user_obj:
415-
elts.append(self._clean_object(obj))
414+
for item in user_obj:
415+
elts.append(self._clean_object(item))
416416
return elts
417417
elif isinstance(user_obj, Var):
418418
return self._expand_value_variable(user_obj)
@@ -1510,10 +1510,14 @@ def woql_as(self, *args):
15101510
def file(self, fpath, opts=None):
15111511
"""Provides details of a file source in a JSON format that includes a URL property
15121512
1513+
Note: CSV files can no longer be read from the filesystem. Only files submitted
1514+
as part of the request can be processed. Use remote() for URLs or submit files
1515+
via the API.
1516+
15131517
Parameters
15141518
----------
1515-
fpath : dict
1516-
file data source in a JSON format
1519+
fpath : dict or str
1520+
file data source in a JSON format or file path
15171521
opts : input options
15181522
optional
15191523
@@ -1523,7 +1527,7 @@ def file(self, fpath, opts=None):
15231527
query object that can be chained and/or execute
15241528
Example
15251529
-------
1526-
To load a local csv file:
1530+
To reference a file (must be submitted with request):
15271531
>>> WOQLQuery().file("/app/local_files/my.csv")
15281532
See Also
15291533
--------
@@ -1537,8 +1541,10 @@ def file(self, fpath, opts=None):
15371541
if self._cursor.get("@type"):
15381542
self._wrap_cursor_with_and()
15391543
self._cursor["@type"] = "QueryResource"
1540-
fpath["@type"] = "Source"
1541-
self._cursor["source"] = fpath
1544+
if isinstance(fpath, str):
1545+
self._cursor["source"] = {"@type": "Source", "file": fpath}
1546+
else:
1547+
self._cursor["source"] = fpath
15421548
self._cursor["format"] = "csv"
15431549
if opts:
15441550
self._cursor["options"] = opts
@@ -1600,21 +1606,45 @@ def remote(self, uri, opts=None):
16001606
if self._cursor.get("@type"):
16011607
self._wrap_cursor_with_and()
16021608
self._cursor["@type"] = "QueryResource"
1603-
uri["@type"] = "Source"
1604-
self._cursor["source"] = uri
1609+
if isinstance(uri, dict):
1610+
uri["@type"] = "Source"
1611+
self._cursor["source"] = uri
1612+
else:
1613+
self._cursor["source"] = {"@type": "Source", "url": uri}
16051614
self._cursor["format"] = "csv"
16061615
if opts:
16071616
self._cursor["options"] = opts
16081617
return self
16091618

16101619
def post(self, fpath, opts=None):
1620+
"""Specifies a file to be posted as part of the request for processing.
1621+
1622+
Note: CSV files can no longer be read from the filesystem. Only files submitted
1623+
as part of the request can be processed. This method should be used with files
1624+
that are uploaded via the API.
1625+
1626+
Parameters
1627+
----------
1628+
fpath : str or dict
1629+
file path/identifier or dict with file details
1630+
opts : dict, optional
1631+
additional options for file processing
1632+
1633+
Returns
1634+
-------
1635+
WOQLQuery object
1636+
query object that can be chained and/or execute
1637+
"""
16111638
if fpath and fpath == "args":
16121639
return ["source", "format", "options"]
16131640
if self._cursor.get("@type"):
16141641
self._wrap_cursor_with_and()
16151642
self._cursor["@type"] = "QueryResource"
1616-
fpath["@type"] = "Source"
1617-
self._cursor["source"] = fpath
1643+
if isinstance(fpath, dict):
1644+
fpath["@type"] = "Source"
1645+
self._cursor["source"] = fpath
1646+
else:
1647+
self._cursor["source"] = {"@type": "Source", "post": fpath}
16181648
self._cursor["format"] = "csv"
16191649
if opts:
16201650
self._cursor["options"] = opts

0 commit comments

Comments
 (0)