From 1d007ad09f4cd1d91e35652e95ea47959f059050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Thu, 22 Dec 2016 15:10:20 -0500 Subject: [PATCH] Move entity builders to builders package Change-Id: Iecce1bfd080612ae7ab5752047236069ae0d8d99 --- almanach/tests/unit/api/test_api_entity.py | 4 ++-- almanach/tests/unit/api/test_api_instance.py | 4 ++-- almanach/tests/unit/api/test_api_volume_type.py | 4 ++-- .../unit/{builder.py => builders/entity.py} | 16 ++++++---------- .../core/controllers/test_entity_controller.py | 5 +++-- .../core/controllers/test_instance_controller.py | 5 +++-- .../core/controllers/test_volume_controller.py | 7 ++++--- .../controllers/test_volume_type_controller.py | 8 ++++---- .../unit/storage/drivers/test_mongodb_driver.py | 9 +++++---- 9 files changed, 31 insertions(+), 31 deletions(-) rename almanach/tests/unit/{builder.py => builders/entity.py} (92%) diff --git a/almanach/tests/unit/api/test_api_entity.py b/almanach/tests/unit/api/test_api_entity.py index 412a81a..18ad007 100644 --- a/almanach/tests/unit/api/test_api_entity.py +++ b/almanach/tests/unit/api/test_api_entity.py @@ -21,8 +21,8 @@ from voluptuous import Invalid from almanach.core import exception from almanach.tests.unit.api import base_api -from almanach.tests.unit.builder import a -from almanach.tests.unit.builder import instance +from almanach.tests.unit.builders.entity import a +from almanach.tests.unit.builders.entity import instance class ApiEntityTest(base_api.BaseApi): diff --git a/almanach/tests/unit/api/test_api_instance.py b/almanach/tests/unit/api/test_api_instance.py index 3863b87..b964815 100644 --- a/almanach/tests/unit/api/test_api_instance.py +++ b/almanach/tests/unit/api/test_api_instance.py @@ -20,8 +20,8 @@ from hamcrest import has_length from almanach.core import exception from almanach.tests.unit.api import base_api -from almanach.tests.unit.builder import a -from almanach.tests.unit.builder import instance +from almanach.tests.unit.builders.entity import a +from almanach.tests.unit.builders.entity import instance class ApiInstanceTest(base_api.BaseApi): diff --git a/almanach/tests/unit/api/test_api_volume_type.py b/almanach/tests/unit/api/test_api_volume_type.py index a7b0d87..8709ada 100644 --- a/almanach/tests/unit/api/test_api_volume_type.py +++ b/almanach/tests/unit/api/test_api_volume_type.py @@ -21,8 +21,8 @@ from hamcrest import has_length from almanach.core import exception from almanach.tests.unit.api import base_api -from almanach.tests.unit.builder import a -from almanach.tests.unit.builder import volume_type +from almanach.tests.unit.builders.entity import a +from almanach.tests.unit.builders.entity import volume_type class ApiVolumeTypeTest(base_api.BaseApi): diff --git a/almanach/tests/unit/builder.py b/almanach/tests/unit/builders/entity.py similarity index 92% rename from almanach/tests/unit/builder.py rename to almanach/tests/unit/builders/entity.py index d236192..d4cdca9 100644 --- a/almanach/tests/unit/builder.py +++ b/almanach/tests/unit/builders/entity.py @@ -14,14 +14,10 @@ from copy import copy from datetime import datetime +import pytz from uuid import uuid4 -import pytz - -from almanach.core.model import build_entity_from_dict -from almanach.core.model import Instance -from almanach.core.model import Volume -from almanach.core.model import VolumeType +from almanach.core import model class Builder(object): @@ -33,7 +29,7 @@ class Builder(object): class EntityBuilder(Builder): def build(self): - return build_entity_from_dict(self.dict_object) + return model.build_entity_from_dict(self.dict_object) def with_id(self, entity_id): self.dict_object["entity_id"] = entity_id @@ -103,7 +99,7 @@ class VolumeBuilder(EntityBuilder): class VolumeTypeBuilder(Builder): def build(self): - return VolumeType(**self.dict_object) + return model.VolumeType(**self.dict_object) def with_volume_type_id(self, volume_type_id): self.dict_object["volume_type_id"] = volume_type_id @@ -127,7 +123,7 @@ def instance(): "distro": "windows", "version": "2012r2" }, - "entity_type": Instance.TYPE, + "entity_type": model.Instance.TYPE, "name": "some-instance", "metadata": { "a_metadata.to_filter": "include.this", @@ -145,7 +141,7 @@ def volume(): "last_event": datetime(2014, 1, 1, 0, 0, 0, 0, pytz.utc), "volume_type": "SF400", "size": 1000000, - "entity_type": Volume.TYPE, + "entity_type": model.Volume.TYPE, "name": "some-volume", "attached_to": None, }) diff --git a/almanach/tests/unit/core/controllers/test_entity_controller.py b/almanach/tests/unit/core/controllers/test_entity_controller.py index e0e732d..4d56217 100644 --- a/almanach/tests/unit/core/controllers/test_entity_controller.py +++ b/almanach/tests/unit/core/controllers/test_entity_controller.py @@ -25,9 +25,10 @@ import pytz from almanach.core.controllers import entity_controller from almanach.core import exception from almanach.storage.drivers import base_driver + from almanach.tests.unit import base -from almanach.tests.unit.builder import a -from almanach.tests.unit.builder import instance +from almanach.tests.unit.builders.entity import a +from almanach.tests.unit.builders.entity import instance class EntityControllerTest(base.BaseTestCase): diff --git a/almanach/tests/unit/core/controllers/test_instance_controller.py b/almanach/tests/unit/core/controllers/test_instance_controller.py index 19f16c4..fa25503 100644 --- a/almanach/tests/unit/core/controllers/test_instance_controller.py +++ b/almanach/tests/unit/core/controllers/test_instance_controller.py @@ -21,9 +21,10 @@ from almanach.core.controllers import instance_controller from almanach.core import exception from almanach.core import model from almanach.storage.drivers import base_driver + from almanach.tests.unit import base -from almanach.tests.unit.builder import a -from almanach.tests.unit.builder import instance +from almanach.tests.unit.builders.entity import a +from almanach.tests.unit.builders.entity import instance class InstanceControllerTest(base.BaseTestCase): diff --git a/almanach/tests/unit/core/controllers/test_volume_controller.py b/almanach/tests/unit/core/controllers/test_volume_controller.py index cd1652e..16b0c4e 100644 --- a/almanach/tests/unit/core/controllers/test_volume_controller.py +++ b/almanach/tests/unit/core/controllers/test_volume_controller.py @@ -22,10 +22,11 @@ from almanach.core.controllers import volume_controller from almanach.core import exception from almanach.core import model from almanach.storage.drivers import base_driver + from almanach.tests.unit import base -from almanach.tests.unit.builder import a -from almanach.tests.unit.builder import volume -from almanach.tests.unit.builder import volume_type +from almanach.tests.unit.builders.entity import a +from almanach.tests.unit.builders.entity import volume +from almanach.tests.unit.builders.entity import volume_type class VolumeControllerTest(base.BaseTestCase): diff --git a/almanach/tests/unit/core/controllers/test_volume_type_controller.py b/almanach/tests/unit/core/controllers/test_volume_type_controller.py index 2b4c5b0..45150bc 100644 --- a/almanach/tests/unit/core/controllers/test_volume_type_controller.py +++ b/almanach/tests/unit/core/controllers/test_volume_type_controller.py @@ -12,13 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from flexmock import flexmock - from almanach.core.controllers import volume_type_controller from almanach.storage.drivers import base_driver +from flexmock import flexmock + from almanach.tests.unit import base -from almanach.tests.unit.builder import a -from almanach.tests.unit.builder import volume_type +from almanach.tests.unit.builders.entity import a +from almanach.tests.unit.builders.entity import volume_type class VolumeTypeControllerTest(base.BaseTestCase): diff --git a/almanach/tests/unit/storage/drivers/test_mongodb_driver.py b/almanach/tests/unit/storage/drivers/test_mongodb_driver.py index 081378f..d8f4348 100644 --- a/almanach/tests/unit/storage/drivers/test_mongodb_driver.py +++ b/almanach/tests/unit/storage/drivers/test_mongodb_driver.py @@ -21,11 +21,12 @@ import pytz from almanach.core import exception from almanach.core import model from almanach.storage.drivers import mongodb_driver + from almanach.tests.unit import base -from almanach.tests.unit.builder import a -from almanach.tests.unit.builder import instance -from almanach.tests.unit.builder import volume -from almanach.tests.unit.builder import volume_type +from almanach.tests.unit.builders.entity import a +from almanach.tests.unit.builders.entity import instance +from almanach.tests.unit.builders.entity import volume +from almanach.tests.unit.builders.entity import volume_type class MongoDbDriverTest(base.BaseTestCase):