Skip to content

Commit 19d191b

Browse files
committed
refactor some more
1 parent def759a commit 19d191b

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

datacrunch/instances/instances.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def create(self,
350350
hostname: str,
351351
description: str,
352352
ssh_key_ids: list = [],
353-
location: str = "FIN-01",
353+
location: str = Locations.FIN_01,
354354
startup_script_id: str = None,
355355
volumes: List[Dict] = None,
356356
existing_volumes: List[str] = None,

datacrunch/volumes/volumes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def create(self,
238238
name: str,
239239
size: int,
240240
instance_id: str = None,
241-
location: str = "FIN1",
241+
location: str = Locations.FIN_01,
242242
) -> Volume:
243243
"""Create new volume
244244
@@ -250,7 +250,7 @@ def create(self,
250250
:type size: int
251251
:param instance_id: Instance id to be attached to, defaults to None
252252
:type instance_id: str, optional
253-
:param location: datacenter location, defaults to "FIN1"
253+
:param location: datacenter location, defaults to "FIN-01"
254254
:type location: str, optional
255255
:return: the new volume object
256256
:rtype: Volume

tests/unit_tests/instances/test_instances.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from datacrunch.exceptions import APIException
55
from datacrunch.instances.instances import InstancesService, Instance
6-
from datacrunch.constants import Actions, ErrorCodes
6+
from datacrunch.constants import Actions, ErrorCodes, Locations
77

88
INVALID_REQUEST = ErrorCodes.INVALID_REQUEST
99
INVALID_REQUEST_MESSAGE = 'Your existence is invalid'
@@ -18,7 +18,7 @@
1818
INSTANCE_DESCRIPTION = "hope you enjoy your GPU"
1919
INSTANCE_STATUS = 'running'
2020
INSTANCE_PRICE_PER_HOUR = 0.60
21-
INSTANCE_LOCATION = 'FIN1'
21+
INSTANCE_LOCATION = Locations.FIN_01
2222
INSTANCE_IP = '1.2.3.4'
2323
INSTANCE_CREATED_AT = "whatchalookingatboy?"
2424
INSTANCE_OS_VOLUME = {"name": "os volume", "size": 50}

tests/unit_tests/volumes/test_volumes.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33

44
from datacrunch.exceptions import APIException
55
from datacrunch.volumes.volumes import VolumesService, Volume
6-
from datacrunch.constants import VolumeStatus, VolumeTypes, VolumeActions, ErrorCodes
6+
from datacrunch.constants import VolumeStatus, VolumeTypes, VolumeActions, ErrorCodes, Locations
77

88
INVALID_REQUEST = ErrorCodes.INVALID_REQUEST
99
INVALID_REQUEST_MESSAGE = 'Your existence is invalid'
1010

1111
INSTANCE_ID = "4fee633c-b119-4447-af9c-70ba17675fc5"
1212

13-
FIN1 = "FIN1"
1413
NVME = "NVMe"
1514
HDD = "HDD"
1615
TARGET_VDA = "vda"
@@ -39,7 +38,7 @@
3938
"name": NVME_VOL_NAME,
4039
"size": NVME_VOL_SIZE,
4140
"type": NVME,
42-
"location_code": FIN1,
41+
"location_code": Locations.FIN_01,
4342
"is_os_volume": True,
4443
"created_at": NVME_VOL_CREATED_AT,
4544
"target": TARGET_VDA,
@@ -53,7 +52,7 @@
5352
"name": HDD_VOL_NAME,
5453
"size": HDD_VOL_SIZE,
5554
"type": HDD,
56-
"location_code": FIN1,
55+
"location_code": Locations.FIN_01,
5756
"is_os_volume": False,
5857
"created_at": HDD_VOL_CREATED_AT,
5958
"target": None,
@@ -82,7 +81,7 @@ def test_initialize_a_volume(self):
8281
assert volume.name == HDD_VOL_NAME
8382
assert volume.size == HDD_VOL_SIZE
8483
assert volume.type == HDD
85-
assert volume.location == FIN1
84+
assert volume.location == Locations.FIN_01
8685
assert volume.is_os_volume == False
8786
assert volume.created_at == HDD_VOL_CREATED_AT
8887
assert volume.target == None
@@ -113,7 +112,7 @@ def test_get_volumes(self, volumes_service, endpoint):
113112
assert volume_nvme.name == NVME_VOL_NAME
114113
assert volume_nvme.size == NVME_VOL_SIZE
115114
assert volume_nvme.type == NVME
116-
assert volume_nvme.location == FIN1
115+
assert volume_nvme.location == Locations.FIN_01
117116
assert volume_nvme.is_os_volume
118117
assert volume_nvme.created_at == NVME_VOL_CREATED_AT
119118
assert volume_nvme.target == TARGET_VDA
@@ -125,7 +124,7 @@ def test_get_volumes(self, volumes_service, endpoint):
125124
assert volume_hdd.name == HDD_VOL_NAME
126125
assert volume_hdd.size == HDD_VOL_SIZE
127126
assert volume_hdd.type == HDD
128-
assert volume_hdd.location == FIN1
127+
assert volume_hdd.location == Locations.FIN_01
129128
assert volume_hdd.is_os_volume is False
130129
assert volume_hdd.created_at == HDD_VOL_CREATED_AT
131130
assert volume_hdd.target is None
@@ -154,7 +153,7 @@ def test_get_volumes_by_status_successful(self, volumes_service, endpoint):
154153
assert volume_nvme.name == NVME_VOL_NAME
155154
assert volume_nvme.size == NVME_VOL_SIZE
156155
assert volume_nvme.type == NVME
157-
assert volume_nvme.location == FIN1
156+
assert volume_nvme.location == Locations.FIN_01
158157
assert volume_nvme.is_os_volume
159158
assert volume_nvme.created_at == NVME_VOL_CREATED_AT
160159
assert volume_nvme.target == TARGET_VDA
@@ -198,7 +197,7 @@ def test_get_volume_by_id_successful(self, volumes_service, endpoint):
198197
assert volume_nvme.name == NVME_VOL_NAME
199198
assert volume_nvme.size == NVME_VOL_SIZE
200199
assert volume_nvme.type == NVME
201-
assert volume_nvme.location == FIN1
200+
assert volume_nvme.location == Locations.FIN_01
202201
assert volume_nvme.is_os_volume
203202
assert volume_nvme.created_at == NVME_VOL_CREATED_AT
204203
assert volume_nvme.target == TARGET_VDA

0 commit comments

Comments
 (0)