Add minimal mocking of elasticbeanstalk:create_environment, describe_environments and list_available_solution_stacks

This commit is contained in:
Niels Laukens 2019-09-04 15:33:15 +02:00
commit 6f23a39fc2
No known key found for this signature in database
GPG key ID: D1397B5A6435A6D8
3 changed files with 1343 additions and 20 deletions

View file

@ -1,12 +1,37 @@
import weakref
import boto.beanstalk
from moto.core import BaseBackend, BaseModel
from .exceptions import InvalidParameterValueError
class FakeEnvironment(BaseModel):
def __init__(self, application, environment_name):
self.environment_name = environment_name
self.application = weakref.proxy(application) # weakref to break circular dependencies
@property
def application_name(self):
return self.application.application_name
class FakeApplication(BaseModel):
def __init__(self, application_name):
self.application_name = application_name
self.environments = dict()
def create_environment(self, environment_name):
if environment_name in self.environments:
raise InvalidParameterValueError
env = FakeEnvironment(
application=self,
environment_name=environment_name,
)
self.environments[environment_name] = env
return env
class EBBackend(BaseBackend):