Skip to content

Commit ce77818

Browse files
committed
improve test coverage
1 parent 2121f06 commit ce77818

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

tests/unit_tests/containers/test_containers.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
QueueLoadScalingTrigger,
2828
UtilizationScalingTrigger,
2929
DockerHubCredentials,
30+
GithubCredentials,
3031
GCRCredentials,
3132
AWSECRCredentials,
3233
CustomRegistryCredentials,
@@ -614,16 +615,20 @@ def test_delete_deployment_environment_variables(self, containers_service, deplo
614615
responses.add(
615616
responses.DELETE,
616617
url,
617-
json=[], # remaining env variables should be empty after deletion
618+
json=ENV_VARS_DATA,
618619
status=200
619620
)
620621

621622
# act
622623
result = containers_service.delete_deployment_environment_variables(
623-
DEPLOYMENT_NAME, CONTAINER_NAME, [ENV_VAR_NAME])
624+
DEPLOYMENT_NAME, CONTAINER_NAME, ["random-env-var-name"])
624625

625626
# assert
626-
assert len(result) == 0
627+
assert result == {CONTAINER_NAME: [EnvVar(
628+
name=ENV_VAR_NAME,
629+
value_or_reference_to_secret=ENV_VAR_VALUE,
630+
type=EnvVarType.PLAIN
631+
)]}
627632
assert responses.assert_call_count(url, 1) is True
628633

629634
@responses.activate
@@ -773,6 +778,29 @@ def test_add_registry_credentials(self, containers_service, registry_credentials
773778
assert responses.calls[0].request.body.decode(
774779
'utf-8') == '{"name": "test-credential", "type": "dockerhub", "username": "username", "access_token": "token"}'
775780

781+
@responses.activate
782+
def test_add_registry_credentials_github(self, containers_service, registry_credentials_endpoint):
783+
# arrange
784+
responses.add(
785+
responses.POST,
786+
registry_credentials_endpoint,
787+
status=201
788+
)
789+
790+
# act
791+
creds = GithubCredentials(
792+
name=REGISTRY_CREDENTIAL_NAME,
793+
username="test-username",
794+
access_token="test-token"
795+
)
796+
containers_service.add_registry_credentials(creds)
797+
798+
# assert
799+
assert responses.assert_call_count(
800+
registry_credentials_endpoint, 1) is True
801+
assert responses.calls[0].request.body.decode(
802+
'utf-8') == '{"name": "test-credential", "type": "ghcr", "username": "test-username", "access_token": "test-token"}'
803+
776804
@responses.activate
777805
def test_add_registry_credentials_gcr(self, containers_service, registry_credentials_endpoint):
778806
# arrange

0 commit comments

Comments
 (0)