1111 FailedJob ,
1212 run_and_track_job ,
1313 BackgroundJobLogger ,
14- get_container_and_volumes
14+ get_container_with_volume_mounts
1515)
1616
1717from kubernetes .client import V1Pod , V1PodCondition
@@ -55,13 +55,27 @@ def test_pod_spec_from_dict():
5555 "args" : ["my_arg" ],
5656 "imagePullPolicy" : "Always" ,
5757 "env" : [{"name" : "my_env" , "value" : "env" }],
58- "volume_mounts" :[
58+ "volume_mounts" : [
5959 {"name" : "Vname" , "mountPath" : "VmountPath" , "host_path" : "VhostPath" }
60- ]
60+ ],
6161 }
62- ]
62+ ],
63+ "volumes" : [
64+ {
65+ "name" : "volname" ,
66+ "csi" : {
67+ "driver" : "blob.csi.azure.com" ,
68+ "volumeAttributes" : {
69+ "containerName" : "volcontainername" ,
70+ "secretName" : "volsecret" ,
71+ "mountOptions" : "-o allow_other --file-cache-timeout-in-seconds=120" ,
72+ },
73+ },
74+ }
75+ ],
6376}
6477
78+
6579def test_pod_spec_with_volume_from_dict ():
6680
6781 labels = {"l1" : "label1" }
@@ -70,14 +84,16 @@ def test_pod_spec_with_volume_from_dict():
7084 assert pod_spec .metadata .name == "name_of_pod"
7185 assert pod_spec .metadata .labels == labels
7286 assert pod_spec .spec .restart_policy == "Never"
87+ assert pod_spec .spec .volumes == [
88+ V1Volume (** dummy_pod_spec_with_volume ['volumes' ][0 ])
89+ ]
7390 container = pod_spec .spec .containers [0 ]
74- assert container .name == dummy_pod_spec ["containers" ][0 ]["name" ]
75- assert container .image == dummy_pod_spec ["containers" ][0 ]["image" ]
76- assert container .env == dummy_pod_spec ["containers" ][0 ]["env" ]
91+ assert container .name == dummy_pod_spec_with_volume ["containers" ][0 ]["name" ]
92+ assert container .image == dummy_pod_spec_with_volume ["containers" ][0 ]["image" ]
93+ assert container .env == dummy_pod_spec_with_volume ["containers" ][0 ]["env" ]
7794 assert container .volume_mounts == [V1VolumeMount (mount_path = "VmountPath" , name = "Vname" )]
7895
7996
80-
8197dummy_container = {
8298 "name" : "container_name" ,
8399 "image" : "my_image" ,
@@ -89,10 +105,9 @@ def test_pod_spec_with_volume_from_dict():
89105 ]
90106 }
91107
92- def test_get_containers_and_volumes ():
93- container , volumes = get_container_and_volumes (dummy_container )
108+ def test_get_container_with_volume_mounts ():
109+ container = get_container_with_volume_mounts (dummy_container )
94110 assert container ['volume_mounts' ] == [V1VolumeMount (mount_path = "VmountPath" , name = "Vname" )]
95- assert volumes == [V1Volume (name = 'Vname' , host_path = V1HostPathVolumeSource (path = 'VhostPath' ))]
96111
97112
98113def test_job_definition ():
0 commit comments