Generalize decorator code.
This commit is contained in:
parent
9076e48fee
commit
d3df810065
@ -1,12 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from .models import apigateway_backends
|
from .models import apigateway_backends
|
||||||
from ..core.models import MockAWS
|
from ..core.models import MockAWS, base_decorator
|
||||||
|
|
||||||
apigateway_backend = apigateway_backends['us-east-1']
|
apigateway_backend = apigateway_backends['us-east-1']
|
||||||
|
mock_apigateway = base_decorator(apigateway_backends)
|
||||||
|
|
||||||
def mock_apigateway(func=None):
|
|
||||||
if func:
|
|
||||||
return MockAWS(apigateway_backends)(func)
|
|
||||||
else:
|
|
||||||
return MockAWS(apigateway_backends)
|
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from .models import autoscaling_backends
|
from .models import autoscaling_backends
|
||||||
from ..core.models import MockAWS
|
from ..core.models import MockAWS, base_decorator
|
||||||
|
|
||||||
autoscaling_backend = autoscaling_backends['us-east-1']
|
autoscaling_backend = autoscaling_backends['us-east-1']
|
||||||
|
mock_autoscaling = base_decorator(autoscaling_backends)
|
||||||
|
|
||||||
def mock_autoscaling(func=None):
|
|
||||||
if func:
|
|
||||||
return MockAWS(autoscaling_backends)(func)
|
|
||||||
else:
|
|
||||||
return MockAWS(autoscaling_backends)
|
|
||||||
|
@ -1,13 +1,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from .models import lambda_backends
|
from .models import lambda_backends
|
||||||
from ..core.models import MockAWS
|
from ..core.models import MockAWS, base_decorator
|
||||||
|
|
||||||
|
|
||||||
lambda_backend = lambda_backends['us-east-1']
|
lambda_backend = lambda_backends['us-east-1']
|
||||||
|
mock_lambda = base_decorator(lambda_backends)
|
||||||
|
|
||||||
def mock_lambda(func=None):
|
|
||||||
if func:
|
|
||||||
return MockAWS(lambda_backends)(func)
|
|
||||||
else:
|
|
||||||
return MockAWS(lambda_backends)
|
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from .models import cloudformation_backends
|
from .models import cloudformation_backends
|
||||||
from ..core.models import MockAWS
|
from ..core.models import MockAWS, base_decorator
|
||||||
|
|
||||||
cloudformation_backend = cloudformation_backends['us-east-1']
|
cloudformation_backend = cloudformation_backends['us-east-1']
|
||||||
|
mock_cloudformation = base_decorator(cloudformation_backends)
|
||||||
|
|
||||||
def mock_cloudformation(func=None):
|
|
||||||
if func:
|
|
||||||
return MockAWS(cloudformation_backends)(func)
|
|
||||||
else:
|
|
||||||
return MockAWS(cloudformation_backends)
|
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
from .models import cloudwatch_backends
|
from .models import cloudwatch_backends
|
||||||
from ..core.models import MockAWS
|
from ..core.models import MockAWS, base_decorator
|
||||||
|
|
||||||
|
|
||||||
cloudwatch_backend = cloudwatch_backends['us-east-1']
|
cloudwatch_backend = cloudwatch_backends['us-east-1']
|
||||||
|
mock_cloudwatch = base_decorator(cloudwatch_backends)
|
||||||
def mock_cloudwatch(func=None):
|
|
||||||
if func:
|
|
||||||
return MockAWS(cloudwatch_backends)(func)
|
|
||||||
else:
|
|
||||||
return MockAWS(cloudwatch_backends)
|
|
||||||
|
@ -186,3 +186,16 @@ class BaseBackend(object):
|
|||||||
return MockAWS({'global': self})(func)
|
return MockAWS({'global': self})(func)
|
||||||
else:
|
else:
|
||||||
return MockAWS({'global': self})
|
return MockAWS({'global': self})
|
||||||
|
|
||||||
|
|
||||||
|
class base_decorator(object):
|
||||||
|
mock_backend = MockAWS
|
||||||
|
|
||||||
|
def __init__(self, backends):
|
||||||
|
self.backends = backends
|
||||||
|
|
||||||
|
def __call__(self, func=None):
|
||||||
|
if func:
|
||||||
|
return self.mock_backend(self.backends)(func)
|
||||||
|
else:
|
||||||
|
return self.mock_backend(self.backends)
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from .models import datapipeline_backends
|
from .models import datapipeline_backends
|
||||||
from ..core.models import MockAWS
|
from ..core.models import MockAWS, base_decorator
|
||||||
|
|
||||||
datapipeline_backend = datapipeline_backends['us-east-1']
|
datapipeline_backend = datapipeline_backends['us-east-1']
|
||||||
|
mock_datapipeline = base_decorator(datapipeline_backends)
|
||||||
|
|
||||||
def mock_datapipeline(func=None):
|
|
||||||
if func:
|
|
||||||
return MockAWS(datapipeline_backends)(func)
|
|
||||||
else:
|
|
||||||
return MockAWS(datapipeline_backends)
|
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from .models import ec2_backends
|
from .models import ec2_backends
|
||||||
from ..core.models import MockAWS
|
from ..core.models import MockAWS, base_decorator
|
||||||
|
|
||||||
ec2_backend = ec2_backends['us-east-1']
|
ec2_backend = ec2_backends['us-east-1']
|
||||||
|
mock_ec2 = base_decorator(ec2_backends)
|
||||||
|
|
||||||
def mock_ec2(func=None):
|
|
||||||
if func:
|
|
||||||
return MockAWS(ec2_backends)(func)
|
|
||||||
else:
|
|
||||||
return MockAWS(ec2_backends)
|
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from .models import ecs_backends
|
from .models import ecs_backends
|
||||||
from ..core.models import MockAWS
|
from ..core.models import MockAWS, base_decorator
|
||||||
|
|
||||||
ecs_backend = ecs_backends['us-east-1']
|
ecs_backend = ecs_backends['us-east-1']
|
||||||
|
mock_ecs = base_decorator(ecs_backends)
|
||||||
def mock_ecs(func=None):
|
|
||||||
if func:
|
|
||||||
return MockAWS(ecs_backends)(func)
|
|
||||||
else:
|
|
||||||
return MockAWS(ecs_backends)
|
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from .models import elb_backends
|
from .models import elb_backends
|
||||||
from ..core.models import MockAWS
|
from ..core.models import MockAWS, base_decorator
|
||||||
|
|
||||||
elb_backend = elb_backends['us-east-1']
|
elb_backend = elb_backends['us-east-1']
|
||||||
|
mock_elb = base_decorator(elb_backends)
|
||||||
|
|
||||||
def mock_elb(func=None):
|
|
||||||
if func:
|
|
||||||
return MockAWS(elb_backends)(func)
|
|
||||||
else:
|
|
||||||
return MockAWS(elb_backends)
|
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from .models import emr_backends
|
from .models import emr_backends
|
||||||
from ..core.models import MockAWS
|
from ..core.models import MockAWS, base_decorator
|
||||||
|
|
||||||
emr_backend = emr_backends['us-east-1']
|
emr_backend = emr_backends['us-east-1']
|
||||||
|
mock_emr = base_decorator(emr_backends)
|
||||||
|
|
||||||
def mock_emr(func=None):
|
|
||||||
if func:
|
|
||||||
return MockAWS(emr_backends)(func)
|
|
||||||
else:
|
|
||||||
return MockAWS(emr_backends)
|
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from .models import glacier_backends
|
from .models import glacier_backends
|
||||||
from ..core.models import MockAWS
|
from ..core.models import MockAWS, base_decorator
|
||||||
|
|
||||||
glacier_backend = glacier_backends['us-east-1']
|
glacier_backend = glacier_backends['us-east-1']
|
||||||
|
mock_glacier = base_decorator(glacier_backends)
|
||||||
|
|
||||||
def mock_glacier(func=None):
|
|
||||||
if func:
|
|
||||||
return MockAWS(glacier_backends)(func)
|
|
||||||
else:
|
|
||||||
return MockAWS(glacier_backends)
|
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from .models import kinesis_backends
|
from .models import kinesis_backends
|
||||||
from ..core.models import MockAWS
|
from ..core.models import MockAWS, base_decorator
|
||||||
|
|
||||||
kinesis_backend = kinesis_backends['us-east-1']
|
kinesis_backend = kinesis_backends['us-east-1']
|
||||||
|
mock_kinesis = base_decorator(kinesis_backends)
|
||||||
|
|
||||||
def mock_kinesis(func=None):
|
|
||||||
if func:
|
|
||||||
return MockAWS(kinesis_backends)(func)
|
|
||||||
else:
|
|
||||||
return MockAWS(kinesis_backends)
|
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from .models import kms_backends
|
from .models import kms_backends
|
||||||
from ..core.models import MockAWS
|
from ..core.models import MockAWS, base_decorator
|
||||||
|
|
||||||
kms_backend = kms_backends['us-east-1']
|
kms_backend = kms_backends['us-east-1']
|
||||||
|
mock_kms = base_decorator(kms_backends)
|
||||||
|
|
||||||
def mock_kms(func=None):
|
|
||||||
if func:
|
|
||||||
return MockAWS(kms_backends)(func)
|
|
||||||
else:
|
|
||||||
return MockAWS(kms_backends)
|
|
||||||
|
@ -1,13 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from .models import opsworks_backends
|
from .models import opsworks_backends
|
||||||
from ..core.models import MockAWS
|
from ..core.models import MockAWS, base_decorator
|
||||||
|
|
||||||
opsworks_backend = opsworks_backends['us-east-1']
|
opsworks_backend = opsworks_backends['us-east-1']
|
||||||
|
mock_opsworks = base_decorator(opsworks_backends)
|
||||||
|
|
||||||
def mock_opsworks(func=None):
|
|
||||||
if func:
|
|
||||||
return MockAWS(opsworks_backends)(func)
|
|
||||||
else:
|
|
||||||
return MockAWS(opsworks_backends)
|
|
||||||
|
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from .models import rds_backends
|
from .models import rds_backends
|
||||||
from ..core.models import MockAWS
|
from ..core.models import MockAWS, base_decorator
|
||||||
|
|
||||||
rds_backend = rds_backends['us-east-1']
|
rds_backend = rds_backends['us-east-1']
|
||||||
|
mock_rds = base_decorator(rds_backends)
|
||||||
|
|
||||||
def mock_rds(func=None):
|
|
||||||
if func:
|
|
||||||
return MockAWS(rds_backends)(func)
|
|
||||||
else:
|
|
||||||
return MockAWS(rds_backends)
|
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from .models import rds2_backends
|
from .models import rds2_backends
|
||||||
from ..core.models import MockAWS
|
from ..core.models import MockAWS, base_decorator
|
||||||
|
|
||||||
rds2_backend = rds2_backends['us-west-1']
|
rds2_backend = rds2_backends['us-west-1']
|
||||||
|
mock_rds2 = base_decorator(rds2_backends)
|
||||||
|
|
||||||
def mock_rds2(func=None):
|
|
||||||
if func:
|
|
||||||
return MockAWS(rds2_backends)(func)
|
|
||||||
else:
|
|
||||||
return MockAWS(rds2_backends)
|
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from .models import redshift_backends
|
from .models import redshift_backends
|
||||||
from ..core.models import MockAWS
|
from ..core.models import MockAWS, base_decorator
|
||||||
|
|
||||||
redshift_backend = redshift_backends['us-east-1']
|
redshift_backend = redshift_backends['us-east-1']
|
||||||
|
mock_redshift = base_decorator(redshift_backends)
|
||||||
|
|
||||||
def mock_redshift(func=None):
|
|
||||||
if func:
|
|
||||||
return MockAWS(redshift_backends)(func)
|
|
||||||
else:
|
|
||||||
return MockAWS(redshift_backends)
|
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from .models import sns_backends
|
from .models import sns_backends
|
||||||
from ..core.models import MockAWS
|
from ..core.models import MockAWS, base_decorator
|
||||||
|
|
||||||
sns_backend = sns_backends['us-east-1']
|
sns_backend = sns_backends['us-east-1']
|
||||||
|
mock_sns = base_decorator(sns_backends)
|
||||||
|
|
||||||
def mock_sns(func=None):
|
|
||||||
if func:
|
|
||||||
return MockAWS(sns_backends)(func)
|
|
||||||
else:
|
|
||||||
return MockAWS(sns_backends)
|
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from .models import sqs_backends
|
from .models import sqs_backends
|
||||||
from ..core.models import MockAWS
|
from ..core.models import MockAWS, base_decorator
|
||||||
|
|
||||||
sqs_backend = sqs_backends['us-east-1']
|
sqs_backend = sqs_backends['us-east-1']
|
||||||
|
mock_sqs = base_decorator(sqs_backends)
|
||||||
|
|
||||||
def mock_sqs(func=None):
|
|
||||||
if func:
|
|
||||||
return MockAWS(sqs_backends)(func)
|
|
||||||
else:
|
|
||||||
return MockAWS(sqs_backends)
|
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from .models import swf_backends
|
from .models import swf_backends
|
||||||
from ..core.models import MockAWS
|
from ..core.models import MockAWS, base_decorator
|
||||||
|
|
||||||
swf_backend = swf_backends['us-east-1']
|
swf_backend = swf_backends['us-east-1']
|
||||||
|
mock_swf = base_decorator(swf_backends)
|
||||||
|
|
||||||
def mock_swf(func=None):
|
|
||||||
if func:
|
|
||||||
return MockAWS(swf_backends)(func)
|
|
||||||
else:
|
|
||||||
return MockAWS(swf_backends)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user