Skip to content

Commit f795b39

Browse files
committed
added a test for cloning two volumes at once
1 parent 5e83fd4 commit f795b39

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

tests/unit_tests/volumes/test_volumes.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
HDD_VOL_CREATED_AT = "2021-06-02T12:56:49.582Z"
3131

3232
RANDOM_VOL_ID = '07d864ee-ba86-451e-85b3-34ef551bd4a2'
33+
RANDOM_VOL2_ID = '72c5c082-7fe7-4d13-bd9e-f529c97d63b3'
3334

3435
NVME_VOLUME = {
3536
"id": NVME_VOL_ID,
@@ -567,3 +568,57 @@ def test_clone_volume_without_input_name_successful(self, volumes_service: Volum
567568
# assert
568569
assert responses.assert_call_count(endpoint, 1) is True
569570
assert cloned_volume.name == CLONED_VOLUME_NAME
571+
572+
def test_clone_two_volumes_successful(self, volumes_service: VolumesService, endpoint):
573+
# arrange
574+
CLONED_VOL1_NAME = "CLONE-" + NVME_VOL_NAME
575+
CLONED_VOL2_NAME = "CLONE-" + HDD_VOL_NAME
576+
577+
# mock response for cloning the volumes
578+
responses.add(
579+
responses.PUT,
580+
endpoint,
581+
status=202,
582+
json=[RANDOM_VOL_ID, RANDOM_VOL2_ID],
583+
match=[
584+
responses.json_params_matcher({
585+
"id": [NVME_VOL_ID, HDD_VOL_ID],
586+
"action": VolumeActions.CLONE,
587+
"name": None,
588+
"type": None
589+
})
590+
]
591+
)
592+
593+
# mock object for the cloned volumes
594+
CLONED_VOL1_GET_MOCK = NVME_VOLUME
595+
CLONED_VOL1_GET_MOCK['id'] = RANDOM_VOL_ID
596+
CLONED_VOL1_GET_MOCK['name'] = CLONED_VOL1_NAME
597+
CLONED_VOL1_GET_MOCK['status'] = VolumeStatus.CLONING
598+
599+
CLONED_VOL2_GET_MOCK = HDD_VOLUME
600+
CLONED_VOL2_GET_MOCK['id'] = RANDOM_VOL2_ID
601+
CLONED_VOL2_GET_MOCK['name'] = CLONED_VOL2_NAME
602+
CLONED_VOL2_GET_MOCK['status'] = VolumeStatus.CLONING
603+
604+
# mock response for getting the cloned volumes
605+
responses.add(
606+
responses.GET,
607+
endpoint + "/" + RANDOM_VOL_ID,
608+
status=200,
609+
json=CLONED_VOL1_GET_MOCK,
610+
)
611+
responses.add(
612+
responses.GET,
613+
endpoint + "/" + RANDOM_VOL2_ID,
614+
status=200,
615+
json=CLONED_VOL2_GET_MOCK,
616+
)
617+
618+
# act
619+
cloned_volume = volumes_service.clone([NVME_VOL_ID, HDD_VOL_ID])
620+
621+
# assert
622+
assert responses.assert_call_count(endpoint, 1) is True
623+
assert cloned_volume[0].name == CLONED_VOL1_NAME
624+
assert cloned_volume[1].name == CLONED_VOL2_NAME

0 commit comments

Comments
 (0)