Repository: getmoto/moto

Issue:
Only First Batch Job Has Tags
When creating batch job definitions using `moto_client.register_job_definition()` and then retrieving all definitions using `moto_client.describe_job_definitions()`, only the first registered job definition has tags. The second registered definition, and all subsequent definitions, have an empty tags dictionary, even though tags are passed to `register_job_definition` to create the job.

Here is a test that should pass if all job definitions have the tags that were passed at registration time:

```
import boto3
import moto


AWS_REGION = "us-east-1"


@moto.mock_batch()
def test_second_job_definition_registered_has_no_tags():
    client = boto3.client("batch", region_name=AWS_REGION)

    two_tags = {"Foo": "bar", "Baz": "buzz"}
    container_props = {
        "image": "1234567890123.dkr.ecr.us-east-1.amazonaws.com/test:test",
        "memory": 1024,
        "vcpus": 2,
    }

    client.register_job_definition(
        jobDefinitionName="test-job",
        type="container",
        tags=two_tags,
        parameters={},
        containerProperties=container_props,
    )

    assert len(two_tags) == 2
    container_props["memory"] = 2048
    client.register_job_definition(
        jobDefinitionName="test-job",
        type="container",
        tags=two_tags,
        parameters={},
        containerProperties=container_props,
    )

    job_defs = client.describe_job_definitions()["jobDefinitions"]
    assert len(job_defs) == 2
    assert job_defs[0]["tags"] == two_tags
    assert job_defs[1]["tags"] == two_tags
```

I expect the test to pass (i.e. all the assertions to succeed). Instead, it fails on the last assertion:
```
>       assert job_defs[1]["tags"] == two_tags
E       AssertionError: assert {} == {'Baz': 'buzz', 'Foo': 'bar'}
E         Right contains 2 more items:
E         {'Baz': 'buzz', 'Foo': 'bar'}
E         Full diff:
E         - {'Baz': 'buzz', 'Foo': 'bar'}
E         + {}
```

I am using the Python mocks, with the following versions of moto and boto3/botocore:
```
boto3==1.18.51
botocore==1.21.51
moto==2.2.16
```
Moto is installed into a project-specific virtual environment, using the virtual environment's `pip` binary and passing it a requirements file that contains
```
moto[batch] >= 2.2.9
boto3
```




Discussion:

Resolving patch:
diff --git a/moto/batch/models.py b/moto/batch/models.py
--- a/moto/batch/models.py
+++ b/moto/batch/models.py
@@ -295,7 +295,7 @@ def _validate(self):
         if vcpus < 1:
             raise ClientException("container vcpus limit must be greater than 0")
 
-    def update(self, parameters, _type, container_properties, retry_strategy):
+    def update(self, parameters, _type, container_properties, retry_strategy, tags):
         if parameters is None:
             parameters = self.parameters
 
@@ -316,6 +316,7 @@ def update(self, parameters, _type, container_properties, retry_strategy):
             region_name=self._region,
             revision=self.revision,
             retry_strategy=retry_strategy,
+            tags=tags,
         )
 
     def describe(self):
@@ -1276,9 +1277,9 @@ def register_job_definition(
                 retry_strategy = retry_strategy["attempts"]
             except Exception:
                 raise ClientException("retryStrategy is malformed")
+        if not tags:
+            tags = {}
         if job_def is None:
-            if not tags:
-                tags = {}
             job_def = JobDefinition(
                 def_name,
                 parameters,
@@ -1291,7 +1292,7 @@ def register_job_definition(
         else:
             # Make new jobdef
             job_def = job_def.update(
-                parameters, _type, container_properties, retry_strategy
+                parameters, _type, container_properties, retry_strategy, tags
             )
 
         self._job_definitions[job_def.arn] = job_def


Test patch:
diff --git a/tests/test_batch/test_batch_jobs.py b/tests/test_batch/test_batch_jobs.py
--- a/tests/test_batch/test_batch_jobs.py
+++ b/tests/test_batch/test_batch_jobs.py
@@ -667,3 +667,47 @@ def prepare_job(batch_client, commands, iam_arn, job_def_name):
     )
     job_def_arn = resp["jobDefinitionArn"]
     return job_def_arn, queue_arn
+
+
+@mock_batch
+def test_update_job_definition():
+    _, _, _, _, batch_client = _get_clients()
+
+    tags = [
+        {"Foo1": "bar1", "Baz1": "buzz1"},
+        {"Foo2": "bar2", "Baz2": "buzz2"},
+    ]
+
+    container_props = {
+        "image": "amazonlinux",
+        "memory": 1024,
+        "vcpus": 2,
+    }
+
+    batch_client.register_job_definition(
+        jobDefinitionName="test-job",
+        type="container",
+        tags=tags[0],
+        parameters={},
+        containerProperties=container_props,
+    )
+
+    container_props["memory"] = 2048
+    batch_client.register_job_definition(
+        jobDefinitionName="test-job",
+        type="container",
+        tags=tags[1],
+        parameters={},
+        containerProperties=container_props,
+    )
+
+    job_defs = batch_client.describe_job_definitions(jobDefinitionName="test-job")[
+        "jobDefinitions"
+    ]
+    job_defs.should.have.length_of(2)
+
+    job_defs[0]["containerProperties"]["memory"].should.equal(1024)
+    job_defs[0]["tags"].should.equal(tags[0])
+
+    job_defs[1]["containerProperties"]["memory"].should.equal(2048)
+    job_defs[1]["tags"].should.equal(tags[1])