11import os
22import pytest
33from datacrunch .datacrunch import DataCrunchClient
4+ from datacrunch .constants import Locations , VolumeTypes , VolumeStatus
45
56IN_GITHUB_ACTIONS = os .getenv ("GITHUB_ACTIONS" ) == "true"
67
78
9+ NVMe = VolumeTypes .NVMe
10+
11+
812@pytest .mark .skipif (IN_GITHUB_ACTIONS , reason = "Test doesn't work in Github Actions." )
913@pytest .mark .withoutresponses
1014class TestVolumes ():
1115
1216 def test_get_volumes_from_trash (self , datacrunch_client : DataCrunchClient ):
1317 # create new volume
1418 volume = datacrunch_client .volumes .create (
15- type = datacrunch_client . constants . volume_types . NVMe , name = "test_volume" , size = 100 )
19+ type = NVMe , name = "test_volume" , size = 100 )
1620
1721 # delete volume
1822 datacrunch_client .volumes .delete (volume .id )
@@ -29,7 +33,7 @@ def test_get_volumes_from_trash(self, datacrunch_client: DataCrunchClient):
2933 def test_permanently_delete_detached_volumes (seld , datacrunch_client ):
3034 # create new volume
3135 volume = datacrunch_client .volumes .create (
32- type = datacrunch_client . constants . volume_types . NVMe , name = "test_volume" , size = 100 )
36+ type = NVMe , name = "test_volume" , size = 100 )
3337
3438 # permanently delete the detached volume
3539 datacrunch_client .volumes .delete (volume .id , is_permanent = True )
@@ -49,7 +53,7 @@ def test_permanently_delete_detached_volumes(seld, datacrunch_client):
4953 def test_permanently_delete_a_deleted_volume_from_trash (self , datacrunch_client ):
5054 # create new volume
5155 volume = datacrunch_client .volumes .create (
52- type = datacrunch_client . constants . volume_types . NVMe , name = "test_volume" , size = 100 )
56+ type = NVMe , name = "test_volume" , size = 100 )
5357
5458 # delete volume
5559 datacrunch_client .volumes .delete (volume .id )
@@ -68,3 +72,16 @@ def test_permanently_delete_a_deleted_volume_from_trash(self, datacrunch_client)
6872
6973 # assert volume is not in trash
7074 assert volume .id not in [v .id for v in volumes ]
75+
76+ def test_create_volume (self , datacrunch_client ):
77+ # create new volume
78+ volume = datacrunch_client .volumes .create (
79+ type = NVMe , name = "test_volume" , size = 100 , location = Locations .FIN_01 )
80+
81+ # assert volume is created
82+ assert volume .id is not None
83+ assert volume .location == Locations .FIN_01
84+ assert volume .status == VolumeStatus .ORDERED or volume .status == VolumeStatus .DETACHED
85+
86+ # cleaning: delete volume
87+ datacrunch_client .volumes .delete (volume .id , is_permanent = True )
0 commit comments