Add sub-minimal mocking of elasticbeanstalk:create_application()

This commit is contained in:
Niels Laukens 2019-09-03 16:10:32 +02:00
commit 336f50349a
No known key found for this signature in database
GPG key ID: D1397B5A6435A6D8
7 changed files with 181 additions and 5 deletions

37
moto/eb/models.py Normal file
View file

@ -0,0 +1,37 @@
import boto.beanstalk
from moto.core import BaseBackend, BaseModel
from .exceptions import InvalidParameterValueError
class FakeApplication(BaseModel):
def __init__(self, application_name):
self.application_name = application_name
class EBBackend(BaseBackend):
def __init__(self, region):
self.region = region
self.applications = dict()
def reset(self):
# preserve region
region = self.region
self._reset_model_refs()
self.__dict__ = {}
self.__init__(region)
def create_application(self, application_name):
if application_name in self.applications:
raise InvalidParameterValueError(
"Application {} already exists.".format(application_name)
)
new_app = FakeApplication(
application_name=application_name,
)
self.applications[application_name] = new_app
return new_app
eb_backends = dict((region.name, EBBackend(region.name))
for region in boto.beanstalk.regions())