diff --git a/moto/moto_api/_internal/responses.py b/moto/moto_api/_internal/responses.py index bcde07da2..d95c1c011 100644 --- a/moto/moto_api/_internal/responses.py +++ b/moto/moto_api/_internal/responses.py @@ -68,7 +68,7 @@ class MotoAPIResponse(BaseResponse): if not attr.startswith("_"): try: json.dumps(getattr(instance, attr)) - except (TypeError, AttributeError): + except (TypeError, AttributeError, ValueError): pass else: inst_result[attr] = getattr(instance, attr) diff --git a/tests/test_core/test_moto_api.py b/tests/test_core/test_moto_api.py index cac92f034..0826f2baa 100644 --- a/tests/test_core/test_moto_api.py +++ b/tests/test_core/test_moto_api.py @@ -14,6 +14,7 @@ base_url = ( if settings.TEST_SERVER_MODE else "http://motoapi.amazonaws.com" ) +data_url = f"{base_url}/moto-api/data.json" @mock_sqs @@ -33,13 +34,24 @@ def test_data_api(): conn = boto3.client("sqs", region_name="us-west-1") conn.create_queue(QueueName="queue1") - res = requests.post(f"{base_url}/moto-api/data.json") - queues = res.json()["sqs"]["Queue"] + queues = requests.post(data_url).json()["sqs"]["Queue"] len(queues).should.equal(1) queue = queues[0] queue["name"].should.equal("queue1") +@mock_s3 +def test_overwriting_s3_object_still_returns_data(): + if settings.TEST_SERVER_MODE: + raise SkipTest("No point in testing this behaves the same in ServerMode") + s3 = boto3.client("s3", region_name="us-east-1") + s3.create_bucket(Bucket="test") + s3.put_object(Bucket="test", Body=b"t", Key="file.txt") + assert len(requests.post(data_url).json()["s3"]["FakeKey"]) == 1 + s3.put_object(Bucket="test", Body=b"t", Key="file.txt") + assert len(requests.post(data_url).json()["s3"]["FakeKey"]) == 2 + + @mock_autoscaling def test_creation_error__data_api_still_returns_thing(): if settings.TEST_SERVER_MODE: