Repository: getmoto/moto

Issue:
{AttributeError}type object 'FakeTrainingJob' has no attribute 'arn_formatter'
I've encountered what I think is a bug.

Whenever I try to call describe_training_job on a sagemaker client, and I give a training job name that doesn't exist, like so:

```
@mock_sagemaker 
def test_fail_describe(self): 
       boto3.client('sagemaker').describe_training_job(TrainingJobName='non_existent_training_job')
```

What I get is an `{AttributeError}type object 'FakeTrainingJob' has no attribute 'arn_formatter'`, 
but i was expecting a ValidationError.

The problem seems to be in moto/sagemaker/models.py at line 1868


Discussion:
Thanks for raising this @vittoema96! Marking it as a bug.

Patch:
diff --git a/moto/sagemaker/models.py b/moto/sagemaker/models.py
--- a/moto/sagemaker/models.py
+++ b/moto/sagemaker/models.py
@@ -165,8 +165,8 @@ def __init__(
         self.debug_rule_configurations = debug_rule_configurations
         self.tensor_board_output_config = tensor_board_output_config
         self.experiment_config = experiment_config
-        self.training_job_arn = arn_formatter(
-            "training-job", training_job_name, account_id, region_name
+        self.training_job_arn = FakeTrainingJob.arn_formatter(
+            training_job_name, account_id, region_name
         )
         self.creation_time = self.last_modified_time = datetime.now().strftime(
             "%Y-%m-%d %H:%M:%S"
@@ -219,6 +219,10 @@ def response_object(self):
     def response_create(self):
         return {"TrainingJobArn": self.training_job_arn}
 
+    @staticmethod
+    def arn_formatter(name, account_id, region_name):
+        return arn_formatter("training-job", name, account_id, region_name)
+
 
 class FakeEndpoint(BaseObject, CloudFormationModel):
     def __init__(
@@ -1865,22 +1869,12 @@ def describe_training_job(self, training_job_name):
             return self.training_jobs[training_job_name].response_object
         except KeyError:
             message = "Could not find training job '{}'.".format(
-                FakeTrainingJob.arn_formatter(training_job_name, self.region_name)
-            )
-            raise ValidationError(message=message)
-
-    def delete_training_job(self, training_job_name):
-        try:
-            del self.training_jobs[training_job_name]
-        except KeyError:
-            message = "Could not find endpoint configuration '{}'.".format(
-                FakeTrainingJob.arn_formatter(training_job_name, self.region_name)
+                FakeTrainingJob.arn_formatter(
+                    training_job_name, self.account_id, self.region_name
+                )
             )
             raise ValidationError(message=message)
 
-    def _update_training_job_details(self, training_job_name, details_json):
-        self.training_jobs[training_job_name].update(details_json)
-
     def list_training_jobs(
         self,
         next_token,
diff --git a/moto/sagemaker/responses.py b/moto/sagemaker/responses.py
--- a/moto/sagemaker/responses.py
+++ b/moto/sagemaker/responses.py
@@ -256,12 +256,6 @@ def describe_training_job(self):
         response = self.sagemaker_backend.describe_training_job(training_job_name)
         return json.dumps(response)
 
-    @amzn_request_id
-    def delete_training_job(self):
-        training_job_name = self._get_param("TrainingJobName")
-        self.sagemaker_backend.delete_training_job(training_job_name)
-        return 200, {}, json.dumps("{}")
-
     @amzn_request_id
     def create_notebook_instance_lifecycle_config(self):
         lifecycle_configuration = (


Test patch:
diff --git a/tests/test_sagemaker/test_sagemaker_training.py b/tests/test_sagemaker/test_sagemaker_training.py
--- a/tests/test_sagemaker/test_sagemaker_training.py
+++ b/tests/test_sagemaker/test_sagemaker_training.py
@@ -441,3 +441,15 @@ def test_delete_tags_from_training_job():
 
     response = client.list_tags(ResourceArn=resource_arn)
     assert response["Tags"] == []
+
+
+@mock_sagemaker
+def test_describe_unknown_training_job():
+    client = boto3.client("sagemaker", region_name="us-east-1")
+    with pytest.raises(ClientError) as exc:
+        client.describe_training_job(TrainingJobName="unknown")
+    err = exc.value.response["Error"]
+    err["Code"].should.equal("ValidationException")
+    err["Message"].should.equal(
+        f"Could not find training job 'arn:aws:sagemaker:us-east-1:{ACCOUNT_ID}:training-job/unknown'."
+    )