diff --git a/moto/lakeformation/models.py b/moto/lakeformation/models.py index 18cd77abb..b5141dad4 100644 --- a/moto/lakeformation/models.py +++ b/moto/lakeformation/models.py @@ -56,6 +56,8 @@ class LakeFormationBackend(BaseBackend): return self.resources[resource_arn] def deregister_resource(self, resource_arn: str) -> None: + if resource_arn not in self.resources: + raise EntityNotFound del self.resources[resource_arn] def register_resource(self, resource_arn: str, role_arn: str) -> None: diff --git a/tests/test_lakeformation/test_lakeformation.py b/tests/test_lakeformation/test_lakeformation.py index bd496734d..69ad2d68e 100644 --- a/tests/test_lakeformation/test_lakeformation.py +++ b/tests/test_lakeformation/test_lakeformation.py @@ -41,6 +41,11 @@ def test_deregister_resource(): err = exc.value.response["Error"] assert err["Code"] == "EntityNotFoundException" + with pytest.raises(ClientError) as exc: + client.deregister_resource(ResourceArn="some arn") + err = exc.value.response["Error"] + assert err["Code"] == "EntityNotFoundException" + @mock_lakeformation def test_list_resources():