Repository: getmoto/moto

Issue:
CodeDeploy: list_deployment_groups and get_deployment_group fixes
* list_deployment_groups should return list of group names
Currently `list_deployment_groups` returns deployment group IDs instead of group names


* get_deployment_group should return deploymentGroupId

References:
http://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/codedeploy/client/list_deployment_groups.html
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/codedeploy/client/get_deployment_group.html

Discussion:

Solution patch:
diff --git a/moto/codedeploy/models.py b/moto/codedeploy/models.py
index 80199a9e0..5412fff41 100644
--- a/moto/codedeploy/models.py
+++ b/moto/codedeploy/models.py
@@ -117,6 +117,7 @@ class DeploymentGroup(BaseModel):
     def to_dict(self) -> Dict[str, Any]:
         return {
             "applicationName": self.application.application_name,
+            "deploymentGroupId": self.deployment_group_id,
             "deploymentGroupName": self.deployment_group_name,
             "deploymentConfigName": str(self.deployment_config_name),
             "ec2TagFilters": self.ec2_tag_filters,
@@ -507,7 +508,7 @@ class CodeDeployBackend(BaseBackend):
             return []
 
         return [
-            deployment_group.deployment_group_id
+            deployment_group.deployment_group_name
             for deployment_group in self.deployment_groups[application_name].values()
         ]
 
diff --git a/other_langs/tests_go/dynamodbstreams.go b/other_langs/tests_go/dynamodbstreams.go
deleted file mode 100644
index c27a45af2..000000000
--- a/other_langs/tests_go/dynamodbstreams.go
+++ /dev/null
@@ -1,78 +0,0 @@
-package main
-
-import (
-	"context"
-	"github.com/aws/aws-sdk-go-v2/aws"
-	"github.com/aws/aws-sdk-go-v2/config"
-	"github.com/aws/aws-sdk-go-v2/service/dynamodb"
-	"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
-	"github.com/aws/aws-sdk-go-v2/service/dynamodbstreams"
-)
-
-const (
-	Endpoint  = "http://localhost:5000"
-	Region    = "us-east-1"
-	TableName = "TableWithStreamEnabled"
-)
-
-func DescribeStream() *dynamodbstreams.DescribeStreamOutput {
-
-	cfg, err := config.LoadDefaultConfig(context.TODO())
-	if err != nil {
-		panic(err)
-	}
-
-	ddbClient := dynamodb.NewFromConfig(cfg, func(o *dynamodb.Options) {
-		o.BaseEndpoint = aws.String(Endpoint)
-		o.Region = Region
-	})
-
-	result, err := ddbClient.CreateTable(context.TODO(), &dynamodb.CreateTableInput{
-		TableName: aws.String(TableName),
-		AttributeDefinitions: []types.AttributeDefinition{
-			{
-				AttributeName: aws.String("PK"),
-				AttributeType: types.ScalarAttributeTypeS,
-			},
-			{
-				AttributeName: aws.String("SK"),
-				AttributeType: types.ScalarAttributeTypeS,
-			},
-		},
-		KeySchema: []types.KeySchemaElement{
-			{
-				AttributeName: aws.String("PK"),
-				KeyType:       types.KeyTypeHash,
-			},
-			{
-				AttributeName: aws.String("SK"),
-				KeyType:       types.KeyTypeRange,
-			},
-		},
-		ProvisionedThroughput: &types.ProvisionedThroughput{
-			ReadCapacityUnits:  aws.Int64(5),
-			WriteCapacityUnits: aws.Int64(5),
-		},
-		StreamSpecification: &types.StreamSpecification{
-			StreamEnabled:  aws.Bool(true),
-			StreamViewType: "NEW_AND_OLD_IMAGES",
-		},
-	})
-
-	if err != nil {
-		panic(err)
-	}
-
-	streamArn := *result.TableDescription.LatestStreamArn
-	ddbsClient := dynamodbstreams.NewFromConfig(cfg, func(o *dynamodbstreams.Options) {
-		o.BaseEndpoint = aws.String(Endpoint)
-		o.Region = Region
-	})
-	streamInfo, err := ddbsClient.DescribeStream(context.TODO(), &dynamodbstreams.DescribeStreamInput{
-		StreamArn: aws.String(streamArn),
-	})
-	if err != nil {
-		panic(err)
-	}
-	return streamInfo
-}
diff --git a/other_langs/tests_go/dynamodbstreams_test.go b/other_langs/tests_go/dynamodbstreams_test.go
index 80543de2e..f99c3b7d8 100644
--- a/other_langs/tests_go/dynamodbstreams_test.go
+++ b/other_langs/tests_go/dynamodbstreams_test.go
@@ -1,17 +1,85 @@
 package main
 
 import (
-	"fmt"
+	"context"
+	"github.com/aws/aws-sdk-go-v2/aws"
+	"github.com/aws/aws-sdk-go-v2/config"
+	"github.com/aws/aws-sdk-go-v2/credentials"
+	"github.com/aws/aws-sdk-go-v2/service/dynamodb"
+	"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
+	"github.com/aws/aws-sdk-go-v2/service/dynamodbstreams"
 	"strings"
 	"testing"
 )
 
+const (
+	TableName = "TableWithStreamEnabled"
+)
+
 func TestDescribeStream(t *testing.T) {
 
-	result := DescribeStream()
-	streamArn := *result.StreamDescription.StreamArn
+	cfg, err := config.LoadDefaultConfig(
+		context.Background(),
+		config.WithBaseEndpoint("http://localhost:5000"),
+		config.WithRegion("us-east-1"),
+		config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider("EXAMPLE", "EXAMPLE", "EXAMPLE")),
+		config.WithClientLogMode(aws.LogRequestWithBody|aws.LogResponseWithBody),
+	)
+
+	ddbClient := dynamodb.NewFromConfig(cfg)
+
+	CreateTableInput := &dynamodb.CreateTableInput{
+		TableName: aws.String(TableName),
+		AttributeDefinitions: []types.AttributeDefinition{
+			{
+				AttributeName: aws.String("PK"),
+				AttributeType: types.ScalarAttributeTypeS,
+			},
+			{
+				AttributeName: aws.String("SK"),
+				AttributeType: types.ScalarAttributeTypeS,
+			},
+		},
+		KeySchema: []types.KeySchemaElement{
+			{
+				AttributeName: aws.String("PK"),
+				KeyType:       types.KeyTypeHash,
+			},
+			{
+				AttributeName: aws.String("SK"),
+				KeyType:       types.KeyTypeRange,
+			},
+		},
+		ProvisionedThroughput: &types.ProvisionedThroughput{
+			ReadCapacityUnits:  aws.Int64(5),
+			WriteCapacityUnits: aws.Int64(5),
+		},
+		StreamSpecification: &types.StreamSpecification{
+			StreamEnabled:  aws.Bool(true),
+			StreamViewType: "NEW_AND_OLD_IMAGES",
+		},
+	}
+
+	ctx := context.Background()
+	result, err := ddbClient.CreateTable(ctx, CreateTableInput)
+	if err != nil {
+		panic(err)
+	}
+	streamArn := *result.TableDescription.LatestStreamArn
+
+	ddbsClient := dynamodbstreams.NewFromConfig(cfg)
+
+	DescribeStreamInput := &dynamodbstreams.DescribeStreamInput{
+		StreamArn: aws.String(streamArn),
+	}
+
+	streamInfo, err := ddbsClient.DescribeStream(ctx, DescribeStreamInput)
+	if err != nil {
+		panic(err)
+	}
+
+	streamArn = *streamInfo.StreamDescription.StreamArn
 	checkFor := TableName + "/stream/"
-	fmt.Println(streamArn)
 	if strings.Contains(streamArn, checkFor) == false {
 		t.Errorf("StreamArn does not contain our table name [%s].", TableName)
 	}


Test patch:
diff --git a/tests/test_codedeploy/test_codedeploy.py b/tests/test_codedeploy/test_codedeploy.py
index a35fa52d6..ce41ab003 100644
--- a/tests/test_codedeploy/test_codedeploy.py
+++ b/tests/test_codedeploy/test_codedeploy.py
@@ -326,12 +326,15 @@ def test_get_deployment_group():
     client.create_application(
         applicationName=application_name, computePlatform="Lambda"
     )
-    client.create_deployment_group(
+
+    response = client.create_deployment_group(
         applicationName=application_name,
         deploymentGroupName=deployment_group_name,
         serviceRoleArn=service_role_arn,
     )
 
+    deployment_group_id = response["deploymentGroupId"]
+
     response = client.get_deployment_group(
         applicationName=application_name, deploymentGroupName=deployment_group_name
     )
@@ -340,6 +343,7 @@ def test_get_deployment_group():
 
     # required fields
     assert deployment_group_info["applicationName"] == application_name
+    assert deployment_group_info["deploymentGroupId"] == deployment_group_id
     assert deployment_group_info["deploymentGroupName"] == deployment_group_name
     assert deployment_group_info["serviceRoleArn"] == service_role_arn
 
@@ -554,6 +558,11 @@ def test_list_deployment_groups():
     resp = client.list_deployment_groups(applicationName=application_name)
     assert len(resp["deploymentGroups"]) == 2
 
+    # ensure both deployment group names are in the response
+    assert set([deployment_group_name, deployment_group_name2]) == set(
+        resp["deploymentGroups"]
+    )
+
 
 @mock_aws
 def test_application_tagging():
@@ -584,7 +593,7 @@ def test_deployment_group_tagging():
     client.create_application(applicationName=app_name, computePlatform="Server")
 
     initial_tags = [{"Key": "Team", "Value": "Platform"}]
-    response = client.create_deployment_group(
+    client.create_deployment_group(
         applicationName=app_name,
         deploymentGroupName=dg_name,
         serviceRoleArn=service_role_arn,