Skip to content

Commit 6f2bb97

Browse files
committed
Fix test and format
1 parent 4ecab3f commit 6f2bb97

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed

mergin/test/test_client.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
decode_token_data,
2020
TokenError,
2121
ServerType,
22-
ErrorCode
22+
ErrorCode,
2323
)
2424
from ..client_push import push_project_async, push_project_cancel
2525
from ..client_pull import (
@@ -2637,14 +2637,15 @@ def test_error_push_already_named_project(mc: MerginClient):
26372637
project = API_USER + "/" + test_project
26382638
project_dir = os.path.join(TMP_DIR, test_project)
26392639

2640-
try:
2640+
try:
26412641
mc.create_project_and_push(test_project, project_dir)
26422642
except ClientError as e:
26432643
print(e)
2644-
assert e.detail == 'Project with the same name already exists'
2644+
assert e.detail == "Project with the same name already exists"
26452645
assert e.http_error == 409
2646-
assert e.http_method == 'POST'
2647-
assert e.url == 'https://test.dev.merginmaps.com/v1/project/test_plugin'
2646+
assert e.http_method == "POST"
2647+
assert e.url == "https://test.dev.merginmaps.com/v1/project/test_plugin"
2648+
26482649

26492650
def test_error_projects_limit_hit(mcStorage: MerginClient):
26502651
test_project = "test_another_project_above_projects_limit"
@@ -2653,12 +2654,14 @@ def test_error_projects_limit_hit(mcStorage: MerginClient):
26532654
project_dir = os.path.join(TMP_DIR, test_project, API_USER)
26542655

26552656
try:
2656-
mcStorage.create_project_and_push(test_project, project_dir)
2657+
mcStorage.create_project_and_push(test_project_fullname, project_dir)
26572658
except ClientError as e:
2658-
print("BLVAVBLA")
2659-
print(e)
26602659
assert e.server_code == ErrorCode.ProjectsLimitHit.value
2661-
assert e.detail == 'Project with the same name already exists'
2660+
assert (
2661+
e.detail
2662+
== "Maximum number of projects is reached. Please upgrade your subscription\
2663+
to create new projects (ProjectsLimitHit)"
2664+
)
26622665
assert e.http_error == 422
2663-
assert e.http_method == 'POST'
2664-
assert e.url == 'https://test.dev.merginmaps.com/v1/project/test_plugin'
2666+
assert e.http_method == "POST"
2667+
assert e.url == "https://test.dev.merginmaps.com/v1/project/testpluginstorage"

mergin/utils.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -276,20 +276,21 @@ def is_mergin_config(path: str) -> bool:
276276
filename = os.path.basename(path).lower()
277277
return filename == "mergin-config.json"
278278

279+
279280
def bytes_to_human_size(bytes: int):
280281
"""
281-
Convert bytes to human readable size
282-
example :
282+
Convert bytes to human readable size
283+
example :
283284
bytes_to_human_size(5600000) -> "5.3 MB"
284285
"""
285-
precision = 1;
286-
if ( bytes < 1e-5 ):
287-
return "0.0 MB";
288-
elif ( bytes < 1024.0 * 1024.0 ):
289-
return f"{round( bytes / 1024.0, precision )} KB";
290-
elif ( bytes < 1024.0 * 1024.0 * 1024.0 ):
291-
return f"{round( bytes / 1024.0 / 1024.0, precision)} MB";
292-
elif ( bytes < 1024.0 * 1024.0 * 1024.0 * 1024.0 ):
293-
return f"{round( bytes / 1024.0 / 1024.0 / 1024.0, precision )} GB";
286+
precision = 1
287+
if bytes < 1e-5:
288+
return "0.0 MB"
289+
elif bytes < 1024.0 * 1024.0:
290+
return f"{round( bytes / 1024.0, precision )} KB"
291+
elif bytes < 1024.0 * 1024.0 * 1024.0:
292+
return f"{round( bytes / 1024.0 / 1024.0, precision)} MB"
293+
elif bytes < 1024.0 * 1024.0 * 1024.0 * 1024.0:
294+
return f"{round( bytes / 1024.0 / 1024.0 / 1024.0, precision )} GB"
294295
else:
295-
return f"{round( bytes / 1024.0 / 1024.0 / 1024.0 / 1024.0, precision )} TB";
296+
return f"{round( bytes / 1024.0 / 1024.0 / 1024.0 / 1024.0, precision )} TB"

0 commit comments

Comments
 (0)