def_tests_reworked #88

Merged
inex merged 20 commits from def_tests_reworked into master 2024-03-05 16:40:15 +02:00
Collaborator

It also contains a complete refactor of service mover.
Closes #17

It also contains a complete refactor of service mover. Closes #17
houkime added 7 commits 2024-01-29 19:03:41 +02:00
houkime added 1 commit 2024-01-29 19:08:12 +02:00
continuous-integration/drone/push Build is failing Details
e23d5da84f
test(services): remove unused json
houkime requested review from inex 2024-01-29 19:09:43 +02:00
inex requested changes 2024-01-31 07:37:56 +02:00
@ -198,3 +198,3 @@
return ServiceJobMutationReturn(
success=False,
message=f"Service move failure: {job.status_text}",
message=f"Service move failure: {job.status_text}: {job.error}",

Double usage of : in one sentence.

Double usage of `:` in one sentence.
houkime marked this conversation as resolved
@ -50,2 +56,2 @@
folder_names: list[FolderMoveNames],
userdata_location: str,
folder_names: List[FolderMoveNames],
userdata_location: str = None, # deprecated, not used

None cannot be assigned to str. Probably refactor all usages to remove the argument?

None cannot be assigned to str. Probably refactor all usages to remove the argument?
houkime marked this conversation as resolved
@ -59,3 +63,2 @@
service_name = service.get_display_name()
with ReadUserData() as user_data:
if not user_data.get("useBinds", False):
old_volume = service.get_drive()

It is a string, but used like it is a BlockDevice

It is a string, but used like it is a BlockDevice
houkime marked this conversation as resolved
@ -76,1 +106,3 @@
return
def check_volume(new_volume: BlockDevice, service: Service) -> bool:

This function doesn't return bool

This function doesn't return bool
houkime marked this conversation as resolved
@ -183,2 +164,3 @@
progress=current_progress + folder_percentage,
f"/volumes/{new_volume.name}/{folder.name}",
)
progress = current_progress + folder_percentage

Job's progress is Optional[int], so the current_progress might turn out to be None

Job's progress is Optional[int], so the current_progress might turn out to be None

Probably, the Job.progress type should be changed instead

Probably, the Job.progress type should be changed instead
houkime marked this conversation as resolved
@ -246,1 +210,4 @@
def update_volume_in_userdata(service: Service, volume: BlockDevice):
with WriteUserData() as user_data:
service_id = service.get_id()

Probably it is better to be outside of the WriteUserData context

Probably it is better to be outside of the WriteUserData context
houkime marked this conversation as resolved
houkime force-pushed def_tests_reworked from e23d5da84f to 5cb2151a28 2024-02-19 02:12:20 +02:00 Compare
houkime added 1 commit 2024-02-19 02:26:22 +02:00
continuous-integration/drone/push Build is failing Details
9b4617fdbf
refactor(services): fix type annotation
houkime requested review from inex 2024-02-19 02:28:05 +02:00
inex requested changes 2024-02-19 13:59:52 +02:00
@ -0,0 +32,4 @@
handle = move_service_task(service, volume, job)
# Nonblocking
handle()

Black magic

Black magic
houkime marked this conversation as resolved
@ -5,18 +5,25 @@ import strawberry
from selfprivacy_api.graphql import IsAuthenticated
from selfprivacy_api.graphql.common_types.jobs import job_to_api_job
from selfprivacy_api.jobs import JobStatus
from selfprivacy_api.utils.block_devices import BlockDevices

Unused import

Unused import
houkime marked this conversation as resolved
@ -17,0 +21,4 @@
ServiceNotFoundError,
VolumeNotFoundError,
)
from selfprivacy_api.services.moving import MoveError

Unused import

Unused import
houkime marked this conversation as resolved
@ -268,6 +268,18 @@ class Jobs:
return False
# A terse way to call a common operation, for readability

Why not a docstring here?

Why not a docstring here?
houkime marked this conversation as resolved
@ -0,0 +29,4 @@
raise MoveError("Volume is not mounted.")
def check_folders(current_volume: BlockDevice, folders: List[OwnedPath]) -> None:

current_volume declared as BlockDevice but used and passed as str

`current_volume` declared as `BlockDevice` but used and passed as `str`
houkime marked this conversation as resolved
@ -0,0 +55,4 @@
def move_folders_to_volume(
folders: List[OwnedPath],
old_volume_name: str, # TODO: pass an actual validated block device

at least two spaces before inline comment: Flake8(E261)

`at least two spaces before inline comment: Flake8(E261)`
houkime marked this conversation as resolved
@ -13,3 +22,4 @@
from selfprivacy_api import utils
from selfprivacy_api.utils.waitloop import wait_until_true
from selfprivacy_api.utils import ReadUserData, WriteUserData, get_domain

get_domain is unused

`get_domain` is unused
houkime marked this conversation as resolved
@ -272,0 +335,4 @@
report_progress(70, job, f"Making sure {service_name} owns its files...")
try:
ensure_folder_ownership(owned_folders, new_volume, job, self)

Too many arguments

Too many arguments
houkime marked this conversation as resolved
houkime force-pushed def_tests_reworked from 9b4617fdbf to cf7c7f168a 2024-02-29 02:57:49 +02:00 Compare
houkime force-pushed def_tests_reworked from cf7c7f168a to 26a1b298c4 2024-03-01 13:01:20 +02:00 Compare
houkime added 1 commit 2024-03-01 16:32:40 +02:00
continuous-integration/drone/push Build is failing Details
769ca07594
refactor(services): remove too many imports and cleanup
houkime force-pushed def_tests_reworked from 769ca07594 to ee7c41e0c2 2024-03-04 19:39:12 +02:00 Compare
inex approved these changes 2024-03-05 16:39:38 +02:00
inex merged commit 8a607b9609 into master 2024-03-05 16:40:15 +02:00
inex deleted branch def_tests_reworked 2024-03-05 16:40:16 +02:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: SelfPrivacy/selfprivacy-rest-api#88
There is no content yet.