Make sure the repository response_object is json serializable with images
If images had been pushed to a repository, they would be included in the response object, and the json encoder could not serialize the Image class. Since they are not included in the boto response, I just deleted the images field from the response object for Repositories. I also found a duplicate test in the ecr class, so I removed one of them.
This commit is contained in:
parent
8956151e07
commit
b67e10d5c9
@ -58,7 +58,7 @@ class Repository(BaseObject):
|
||||
response_object['repositoryName'] = self.name
|
||||
response_object['repositoryUri'] = self.uri
|
||||
# response_object['createdAt'] = self.created
|
||||
del response_object['arn'], response_object['name']
|
||||
del response_object['arn'], response_object['name'], response_object['images']
|
||||
return response_object
|
||||
|
||||
@classmethod
|
||||
|
@ -152,6 +152,23 @@ def test_describe_repositories_4():
|
||||
len(response['repositories']).should.equal(0)
|
||||
|
||||
|
||||
@mock_ecr
|
||||
def test_describe_repositories_with_image():
|
||||
client = boto3.client('ecr', region_name='us-east-1')
|
||||
_ = client.create_repository(
|
||||
repositoryName='test_repository'
|
||||
)
|
||||
|
||||
_ = client.put_image(
|
||||
repositoryName='test_repository',
|
||||
imageManifest=json.dumps(_create_image_manifest()),
|
||||
imageTag='latest'
|
||||
)
|
||||
|
||||
response = client.describe_repositories(repositoryNames=['test_repository'])
|
||||
len(response['repositories']).should.equal(1)
|
||||
|
||||
|
||||
@mock_ecr
|
||||
def test_delete_repository():
|
||||
client = boto3.client('ecr', region_name='us-east-1')
|
||||
@ -177,14 +194,17 @@ def test_put_image():
|
||||
_ = client.create_repository(
|
||||
repositoryName='test_repository'
|
||||
)
|
||||
|
||||
response = client.put_image(
|
||||
repositoryName='test_repository',
|
||||
imageManifest=json.dumps(_create_image_manifest()),
|
||||
imageTag='latest'
|
||||
)
|
||||
|
||||
response['image']['repositoryName'].should.equal('test_repository')
|
||||
response['image']['imageId']['imageTag'].should.equal('latest')
|
||||
response['image']['imageId']['imageDigest'].should.contain("sha")
|
||||
response['image']['repositoryName'].should.equal('test_repository')
|
||||
response['image']['registryId'].should.equal('012345678910')
|
||||
|
||||
|
||||
@mock_ecr
|
||||
@ -294,22 +314,3 @@ def test_describe_images():
|
||||
response['imageDetails'][0]['imageSizeInBytes'].should.equal(52428800)
|
||||
response['imageDetails'][1]['imageSizeInBytes'].should.equal(52428800)
|
||||
response['imageDetails'][2]['imageSizeInBytes'].should.equal(52428800)
|
||||
|
||||
|
||||
@mock_ecr
|
||||
def test_put_image():
|
||||
client = boto3.client('ecr', region_name='us-east-1')
|
||||
_ = client.create_repository(
|
||||
repositoryName='test_repository'
|
||||
)
|
||||
|
||||
response = client.put_image(
|
||||
repositoryName='test_repository',
|
||||
imageManifest=json.dumps(_create_image_manifest()),
|
||||
imageTag='latest'
|
||||
)
|
||||
|
||||
response['image']['imageId']['imageTag'].should.equal('latest')
|
||||
response['image']['imageId']['imageDigest'].should.contain("sha")
|
||||
response['image']['repositoryName'].should.equal('test_repository')
|
||||
response['image']['registryId'].should.equal('012345678910')
|
Loading…
x
Reference in New Issue
Block a user