Skip to content

Commit c6b36fd

Browse files
committed
Fix formatting
1 parent a398c32 commit c6b36fd

27 files changed

Lines changed: 832 additions & 618 deletions

terminusdb_client/tests/integration_tests/test_client.py

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -397,39 +397,53 @@ def test_get_organization_user_databases(docker_url):
397397
client.create_database(db_name2, team=org_name)
398398

399399
# BEFORE grant: verify our specific databases are NOT accessible to admin user
400-
databases_before = client.get_organization_user_databases(org=org_name, username="admin")
401-
db_names_before = {db['name'] for db in databases_before}
402-
assert db_name not in db_names_before, f"{db_name} should not be accessible before capability grant"
403-
assert db_name2 not in db_names_before, f"{db_name2} should not be accessible before capability grant"
400+
databases_before = client.get_organization_user_databases(
401+
org=org_name, username="admin"
402+
)
403+
db_names_before = {db["name"] for db in databases_before}
404+
assert (
405+
db_name not in db_names_before
406+
), f"{db_name} should not be accessible before capability grant"
407+
assert (
408+
db_name2 not in db_names_before
409+
), f"{db_name2} should not be accessible before capability grant"
404410

405411
# Grant capabilities to admin user for the organization
406412
capability_change = {
407413
"operation": "grant",
408414
"scope": f"Organization/{org_name}",
409415
"user": "User/admin",
410-
"roles": [
411-
"Role/admin"
412-
]
416+
"roles": ["Role/admin"],
413417
}
414418
client.change_capabilities(capability_change)
415419

416420
# AFTER grant: verify our specific databases ARE accessible to admin user
417-
databases_after = client.get_organization_user_databases(org=org_name, username="admin")
418-
db_names_after = {db['name'] for db in databases_after}
421+
databases_after = client.get_organization_user_databases(
422+
org=org_name, username="admin"
423+
)
424+
db_names_after = {db["name"] for db in databases_after}
419425
# Check both our databases are now accessible (order not guaranteed)
420-
assert db_name in db_names_after, f"{db_name} should be accessible after capability grant"
421-
assert db_name2 in db_names_after, f"{db_name2} should be accessible after capability grant"
426+
assert (
427+
db_name in db_names_after
428+
), f"{db_name} should be accessible after capability grant"
429+
assert (
430+
db_name2 in db_names_after
431+
), f"{db_name2} should be accessible after capability grant"
422432
# Verify admin team database does NOT appear in organization results
423-
assert admin_db_name not in db_names_after, f"{admin_db_name} should not appear in {org_name} results"
433+
assert (
434+
admin_db_name not in db_names_after
435+
), f"{admin_db_name} should not appear in {org_name} results"
424436
finally:
425437
# Cleanup: revoke capability, delete databases, delete org
426438
try:
427-
client.change_capabilities({
428-
"operation": "revoke",
429-
"scope": f"Organization/{org_name}",
430-
"user": "User/admin",
431-
"roles": ["Role/admin"]
432-
})
439+
client.change_capabilities(
440+
{
441+
"operation": "revoke",
442+
"scope": f"Organization/{org_name}",
443+
"user": "User/admin",
444+
"roles": ["Role/admin"],
445+
}
446+
)
433447
except Exception:
434448
pass
435449
try:

terminusdb_client/tests/integration_tests/test_schema.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ def test_getting_and_deleting_cheuk(schema_test_db):
168168
cheuk_setup.friend_of = {cheuk_setup}
169169
cheuk_setup.member_of = Team.IT
170170

171-
client.insert_document([cheuk_setup], commit_msg="Setup for test_getting_and_deleting_cheuk")
171+
client.insert_document(
172+
[cheuk_setup], commit_msg="Setup for test_getting_and_deleting_cheuk"
173+
)
172174

173175
# Test: Load and verify
174176
new_schema = WOQLSchema()
@@ -194,7 +196,9 @@ def test_insert_cheuk_again(schema_test_db):
194196
uk_setup = Country()
195197
uk_setup.name = "UK Test 2"
196198
uk_setup.perimeter = []
197-
client.insert_document([uk_setup], commit_msg="Setup country for test_insert_cheuk_again")
199+
client.insert_document(
200+
[uk_setup], commit_msg="Setup country for test_insert_cheuk_again"
201+
)
198202

199203
# Test: Load country and create employee
200204
new_schema = WOQLSchema()
@@ -248,7 +252,10 @@ def test_insert_cheuk_again(schema_test_db):
248252
if item.get("@type") == "Country" and item.get("name") == "UK Test 2":
249253
assert item["perimeter"]
250254
found_country = True
251-
elif item.get("@type") == "Employee" and item.get("@id") == "Employee/cheuk_test_2":
255+
elif (
256+
item.get("@type") == "Employee"
257+
and item.get("@id") == "Employee/cheuk_test_2"
258+
):
252259
assert item["address_of"]["postal_code"] == "A12 345"
253260
assert item["address_of"]["street"] == "123 Abc Street"
254261
assert item["name"] == "Cheuk Test 2"
@@ -300,7 +307,9 @@ def test_get_data_version(schema_test_db):
300307
cheuk.member_of = Team.IT
301308
cheuk._id = "cheuk_test_3"
302309

303-
client.insert_document([location, uk, cheuk], commit_msg="Setup for test_get_data_version")
310+
client.insert_document(
311+
[location, uk, cheuk], commit_msg="Setup for test_get_data_version"
312+
)
304313
result, version = client.get_all_branches(get_data_version=True)
305314
assert version
306315
result, version = client.get_all_documents(
@@ -425,9 +434,9 @@ def test_repeated_object_load(docker_url, test_schema):
425434
client.insert_document(
426435
schema, commit_msg="I am checking in the schema", graph_type="schema"
427436
)
428-
[country_id] = client.insert_document({"@type" : "Country",
429-
"name" : "Romania",
430-
"perimeter" : []})
437+
[country_id] = client.insert_document(
438+
{"@type": "Country", "name": "Romania", "perimeter": []}
439+
)
431440
obj = client.get_document(country_id)
432441
schema.import_objects(obj)
433442
obj2 = client.get_document(country_id)
@@ -446,12 +455,15 @@ def test_key_change_raises_exception(docker_url, test_schema):
446455
client.insert_document(
447456
schema, commit_msg="I am checking in the schema", graph_type="schema"
448457
)
449-
[country_id] = client.insert_document({"@type" : "Country",
450-
"name" : "Romania",
451-
"perimeter" : []})
458+
[country_id] = client.insert_document(
459+
{"@type": "Country", "name": "Romania", "perimeter": []}
460+
)
452461
obj = client.get_document(country_id)
453462
local_obj = schema.import_objects(obj)
454-
with pytest.raises(ValueError, match=r"name has been used to generate the id, hence cannot be changed."):
463+
with pytest.raises(
464+
ValueError,
465+
match=r"name has been used to generate the id, hence cannot be changed.",
466+
):
455467
local_obj.name = "France"
456468
finally:
457469
client.delete_database(db_name)

terminusdb_client/tests/test_errors.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,13 @@ def test_api_error_initialization(self):
233233
# These lines are in the APIError.__init__ method
234234

235235
# We need to mock the parent constructor to avoid the response issue
236-
with patch.object(DatabaseError, '__init__', return_value=None):
236+
with patch.object(DatabaseError, "__init__", return_value=None):
237237
# Now we can create APIError normally
238238
api_error = APIError(
239239
message="Test error message",
240240
err_obj={"error": "details"},
241241
status_code=400,
242-
url="https://example.com/api"
242+
url="https://example.com/api",
243243
)
244244

245245
# Verify the attributes were set (lines 117-120)
@@ -270,14 +270,9 @@ def test_api_error_str_representation(self):
270270
def test_api_error_with_minimal_params(self):
271271
"""Test APIError with minimal parameters"""
272272
# Mock the parent constructor to avoid the response issue
273-
with patch.object(DatabaseError, '__init__', return_value=None):
273+
with patch.object(DatabaseError, "__init__", return_value=None):
274274
# Test with None values (covers edge cases)
275-
api_error = APIError(
276-
message=None,
277-
err_obj=None,
278-
status_code=None,
279-
url=None
280-
)
275+
api_error = APIError(message=None, err_obj=None, status_code=None, url=None)
281276

282277
assert api_error.message is None
283278
assert api_error.error_obj is None

0 commit comments

Comments
 (0)