From bba6d23eaeab974ff1788eb6291b9e44785e5f05 Mon Sep 17 00:00:00 2001 From: Terry Cain Date: Tue, 26 Sep 2017 17:37:26 +0100 Subject: [PATCH] Started on batch --- moto/batch/__init__.py | 6 ++++++ moto/batch/exceptions.py | 3 +++ moto/batch/models.py | 23 +++++++++++++++++++++++ moto/batch/responses.py | 14 ++++++++++++++ tests/test_batch/test_batch.py | 11 +++++++++++ tests/test_batch/test_server.py | 16 ++++++++++++++++ 6 files changed, 73 insertions(+) create mode 100644 moto/batch/__init__.py create mode 100644 moto/batch/exceptions.py create mode 100644 moto/batch/models.py create mode 100644 moto/batch/responses.py create mode 100644 tests/test_batch/test_batch.py create mode 100644 tests/test_batch/test_server.py diff --git a/moto/batch/__init__.py b/moto/batch/__init__.py new file mode 100644 index 000000000..6002b6fc7 --- /dev/null +++ b/moto/batch/__init__.py @@ -0,0 +1,6 @@ +from __future__ import unicode_literals +from .models import batch_backends +from ..core.models import base_decorator + +batch_backend = batch_backends['us-east-1'] +mock_batch = base_decorator(batch_backends) diff --git a/moto/batch/exceptions.py b/moto/batch/exceptions.py new file mode 100644 index 000000000..e598ee7af --- /dev/null +++ b/moto/batch/exceptions.py @@ -0,0 +1,3 @@ +from __future__ import unicode_literals +from moto.core.exceptions import RESTError + diff --git a/moto/batch/models.py b/moto/batch/models.py new file mode 100644 index 000000000..a54b30c32 --- /dev/null +++ b/moto/batch/models.py @@ -0,0 +1,23 @@ +from __future__ import unicode_literals +import boto3 +from moto.core import BaseBackend, BaseModel + + +class BatchBackend(BaseBackend): + def __init__(self, region_name=None): + super(BatchBackend, self).__init__() + self.region_name = region_name + + def reset(self): + region_name = self.region_name + self.__dict__ = {} + self.__init__(region_name) + + def create_compute_environment(self, compute_environment_name, type, state, compute_resources, service_role): + # implement here + return compute_environment_name, compute_environment_arn + # add methods from here + + +available_regions = boto3.session.Session().get_available_regions("batch") +batch_backends = {region: BatchBackend for region in available_regions} diff --git a/moto/batch/responses.py b/moto/batch/responses.py new file mode 100644 index 000000000..d91af8a77 --- /dev/null +++ b/moto/batch/responses.py @@ -0,0 +1,14 @@ +from __future__ import unicode_literals +from moto.core.responses import BaseResponse +from .models import batch_backends + + +class BatchResponse(BaseResponse): + @property + def batch_backend(self): + return batch_backends[self.region] + + # add methods from here + + +# add teampltes from here diff --git a/tests/test_batch/test_batch.py b/tests/test_batch/test_batch.py new file mode 100644 index 000000000..eafd32eae --- /dev/null +++ b/tests/test_batch/test_batch.py @@ -0,0 +1,11 @@ +from __future__ import unicode_literals + +import boto3 +import sure # noqa +from moto import mock_batch + + +@mock_batch +def test_list(): + # do test + pass \ No newline at end of file diff --git a/tests/test_batch/test_server.py b/tests/test_batch/test_server.py new file mode 100644 index 000000000..7c0d2b3a1 --- /dev/null +++ b/tests/test_batch/test_server.py @@ -0,0 +1,16 @@ +from __future__ import unicode_literals + +import sure # noqa + +import moto.server as server +from moto import mock_batch + +''' +Test the different server responses +''' + +@mock_batch +def test_batch_list(): + backend = server.create_backend_app("batch") + test_client = backend.test_client() + # do test \ No newline at end of file