Skip to content

Commit 9ed1131

Browse files
committed
fixes
1 parent a36c1a7 commit 9ed1131

File tree

1 file changed

+47
-27
lines changed

1 file changed

+47
-27
lines changed

tests/unit_tests/containers/test_containers.py

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
VolumeMount,
2222
VolumeMountType,
2323
ComputeResource,
24+
ScalingOptions,
25+
ScalingPolicy,
26+
ScalingTriggers,
27+
QueueLoadScalingTrigger,
28+
UtilizationScalingTrigger,
2429
)
2530
from datacrunch.exceptions import APIException
2631

@@ -407,8 +412,9 @@ def test_get_scaling_options(self, containers_service, deployments_endpoint):
407412
DEPLOYMENT_NAME)
408413

409414
# assert
410-
assert scaling_options["min_replica_count"] == 1
411-
assert scaling_options["max_replica_count"] == 3
415+
assert isinstance(scaling_options, ScalingOptions)
416+
assert scaling_options.min_replica_count == 1
417+
assert scaling_options.max_replica_count == 3
412418
assert responses.assert_call_count(url, 1) is True
413419

414420
@responses.activate
@@ -422,17 +428,30 @@ def test_update_scaling_options(self, containers_service, deployments_endpoint):
422428
status=200
423429
)
424430

431+
# create scaling options object
432+
scaling_options = ScalingOptions(
433+
min_replica_count=1,
434+
max_replica_count=5,
435+
scale_down_policy=ScalingPolicy(delay_seconds=300),
436+
scale_up_policy=ScalingPolicy(delay_seconds=60),
437+
queue_message_ttl_seconds=3600,
438+
concurrent_requests_per_replica=10,
439+
scaling_triggers=ScalingTriggers(
440+
queue_load=QueueLoadScalingTrigger(threshold=0.75),
441+
cpu_utilization=UtilizationScalingTrigger(
442+
enabled=True, threshold=0.8),
443+
gpu_utilization=UtilizationScalingTrigger(enabled=False)
444+
)
445+
)
446+
425447
# act
426-
scaling_options = {
427-
"min_replica_count": 1,
428-
"max_replica_count": 5
429-
}
430448
updated_scaling = containers_service.update_scaling_options(
431449
DEPLOYMENT_NAME, scaling_options)
432450

433451
# assert
434-
assert updated_scaling["min_replica_count"] == 1
435-
assert updated_scaling["max_replica_count"] == 3
452+
assert isinstance(updated_scaling, ScalingOptions)
453+
assert updated_scaling.min_replica_count == 1
454+
assert updated_scaling.max_replica_count == 3
436455
assert responses.assert_call_count(url, 1) is True
437456

438457
@responses.activate
@@ -664,6 +683,26 @@ def test_delete_secret(self, containers_service, secrets_endpoint):
664683

665684
# assert
666685
assert responses.assert_call_count(url, 1) is True
686+
request = responses.calls[0].request
687+
assert "force=False" in request.url
688+
689+
@responses.activate
690+
def test_delete_secret_with_force(self, containers_service, secrets_endpoint):
691+
# arrange
692+
url = f"{secrets_endpoint}/{SECRET_NAME}"
693+
responses.add(
694+
responses.DELETE,
695+
url,
696+
status=200
697+
)
698+
699+
# act
700+
containers_service.delete_secret(SECRET_NAME, force=True)
701+
702+
# assert
703+
assert responses.assert_call_count(url, 1) is True
704+
request = responses.calls[0].request
705+
assert "force=True" in request.url
667706

668707
@responses.activate
669708
def test_get_registry_credentials(self, containers_service, registry_credentials_endpoint):
@@ -783,25 +822,6 @@ def test_add_registry_credentials_custom(self, containers_service, registry_cred
783822
assert responses.assert_call_count(
784823
registry_credentials_endpoint, 1) is True
785824

786-
@responses.activate
787-
def test_delete_secret_with_force(self, containers_service, secrets_endpoint):
788-
# arrange
789-
url = f"{secrets_endpoint}/{SECRET_NAME}"
790-
responses.add(
791-
responses.DELETE,
792-
url,
793-
status=200
794-
)
795-
796-
# act
797-
containers_service.delete_secret(SECRET_NAME, force=True)
798-
799-
# assert
800-
assert responses.assert_call_count(url, 1) is True
801-
# Verify the request included force=True parameter
802-
request = responses.calls[0].request
803-
assert "force=True" in request.url
804-
805825
@responses.activate
806826
def test_delete_registry_credentials(self, containers_service, registry_credentials_endpoint):
807827
# arrange - add response mock

0 commit comments

Comments
 (0)