Implement the remaining registry tests in the new py.test format
This commit is contained in:
parent
77adf9dd77
commit
8c1b0e673c
7 changed files with 1200 additions and 62 deletions
|
@ -1,3 +1,6 @@
|
|||
import random
|
||||
import string
|
||||
|
||||
import pytest
|
||||
|
||||
from Crypto.PublicKey import RSA
|
||||
|
@ -12,11 +15,23 @@ from test.registry.protocol_v2 import V2Protocol
|
|||
def basic_images():
|
||||
""" Returns basic images for push and pull testing. """
|
||||
# Note: order is from base layer down to leaf.
|
||||
parent_bytes = layer_bytes_for_contents('parent contents')
|
||||
image_bytes = layer_bytes_for_contents('some contents')
|
||||
return [
|
||||
Image(id='parentid', bytes=layer_bytes_for_contents('parent contents'),
|
||||
parent_id=None, size=None),
|
||||
Image(id='someid', bytes=layer_bytes_for_contents('some contents'),
|
||||
parent_id='parentid', size=None),
|
||||
Image(id='parentid', bytes=parent_bytes, parent_id=None),
|
||||
Image(id='someid', bytes=image_bytes, parent_id='parentid'),
|
||||
]
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def sized_images():
|
||||
""" Returns basic images (with sizes) for push and pull testing. """
|
||||
# Note: order is from base layer down to leaf.
|
||||
parent_bytes = layer_bytes_for_contents('parent contents', mode='')
|
||||
image_bytes = layer_bytes_for_contents('some contents', mode='')
|
||||
return [
|
||||
Image(id='parentid', bytes=parent_bytes, parent_id=None, size=len(parent_bytes)),
|
||||
Image(id='someid', bytes=image_bytes, parent_id='parentid', size=len(image_bytes)),
|
||||
]
|
||||
|
||||
|
||||
|
@ -25,6 +40,26 @@ def jwk():
|
|||
return RSAKey(key=RSA.generate(2048))
|
||||
|
||||
|
||||
@pytest.fixture(params=[V2Protocol])
|
||||
def v2_protocol(request, jwk):
|
||||
return request.param(jwk)
|
||||
|
||||
|
||||
@pytest.fixture(params=[V1Protocol])
|
||||
def v1_protocol(request, jwk):
|
||||
return request.param(jwk)
|
||||
|
||||
|
||||
@pytest.fixture(params=[V2Protocol])
|
||||
def manifest_protocol(request, jwk):
|
||||
return request.param(jwk)
|
||||
|
||||
|
||||
@pytest.fixture(params=[V1Protocol, V2Protocol])
|
||||
def loginer(request, jwk):
|
||||
return request.param(jwk)
|
||||
|
||||
|
||||
@pytest.fixture(params=[V1Protocol, V2Protocol])
|
||||
def pusher(request, jwk):
|
||||
return request.param(jwk)
|
||||
|
@ -33,3 +68,10 @@ def pusher(request, jwk):
|
|||
@pytest.fixture(params=[V1Protocol, V2Protocol])
|
||||
def puller(request, jwk):
|
||||
return request.param(jwk)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def random_layer_data():
|
||||
size = 4096
|
||||
contents = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(size))
|
||||
return layer_bytes_for_contents(contents)
|
||||
|
|
Reference in a new issue