Moto Dashboard - Don't fail when S3 objects are deleted (#6410)
This commit is contained in:
parent
667bb9aa56
commit
2e3b06bbe5
@ -68,7 +68,7 @@ class MotoAPIResponse(BaseResponse):
|
|||||||
if not attr.startswith("_"):
|
if not attr.startswith("_"):
|
||||||
try:
|
try:
|
||||||
json.dumps(getattr(instance, attr))
|
json.dumps(getattr(instance, attr))
|
||||||
except (TypeError, AttributeError):
|
except (TypeError, AttributeError, ValueError):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
inst_result[attr] = getattr(instance, attr)
|
inst_result[attr] = getattr(instance, attr)
|
||||||
|
@ -14,6 +14,7 @@ base_url = (
|
|||||||
if settings.TEST_SERVER_MODE
|
if settings.TEST_SERVER_MODE
|
||||||
else "http://motoapi.amazonaws.com"
|
else "http://motoapi.amazonaws.com"
|
||||||
)
|
)
|
||||||
|
data_url = f"{base_url}/moto-api/data.json"
|
||||||
|
|
||||||
|
|
||||||
@mock_sqs
|
@mock_sqs
|
||||||
@ -33,13 +34,24 @@ def test_data_api():
|
|||||||
conn = boto3.client("sqs", region_name="us-west-1")
|
conn = boto3.client("sqs", region_name="us-west-1")
|
||||||
conn.create_queue(QueueName="queue1")
|
conn.create_queue(QueueName="queue1")
|
||||||
|
|
||||||
res = requests.post(f"{base_url}/moto-api/data.json")
|
queues = requests.post(data_url).json()["sqs"]["Queue"]
|
||||||
queues = res.json()["sqs"]["Queue"]
|
|
||||||
len(queues).should.equal(1)
|
len(queues).should.equal(1)
|
||||||
queue = queues[0]
|
queue = queues[0]
|
||||||
queue["name"].should.equal("queue1")
|
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
|
@mock_autoscaling
|
||||||
def test_creation_error__data_api_still_returns_thing():
|
def test_creation_error__data_api_still_returns_thing():
|
||||||
if settings.TEST_SERVER_MODE:
|
if settings.TEST_SERVER_MODE:
|
||||||
|
Loading…
Reference in New Issue
Block a user