Move entity builders to builders package
Change-Id: Iecce1bfd080612ae7ab5752047236069ae0d8d99
This commit is contained in:
parent
03b1d2ce86
commit
1d007ad09f
@ -21,8 +21,8 @@ from voluptuous import Invalid
|
|||||||
|
|
||||||
from almanach.core import exception
|
from almanach.core import exception
|
||||||
from almanach.tests.unit.api import base_api
|
from almanach.tests.unit.api import base_api
|
||||||
from almanach.tests.unit.builder import a
|
from almanach.tests.unit.builders.entity import a
|
||||||
from almanach.tests.unit.builder import instance
|
from almanach.tests.unit.builders.entity import instance
|
||||||
|
|
||||||
|
|
||||||
class ApiEntityTest(base_api.BaseApi):
|
class ApiEntityTest(base_api.BaseApi):
|
||||||
|
@ -20,8 +20,8 @@ from hamcrest import has_length
|
|||||||
|
|
||||||
from almanach.core import exception
|
from almanach.core import exception
|
||||||
from almanach.tests.unit.api import base_api
|
from almanach.tests.unit.api import base_api
|
||||||
from almanach.tests.unit.builder import a
|
from almanach.tests.unit.builders.entity import a
|
||||||
from almanach.tests.unit.builder import instance
|
from almanach.tests.unit.builders.entity import instance
|
||||||
|
|
||||||
|
|
||||||
class ApiInstanceTest(base_api.BaseApi):
|
class ApiInstanceTest(base_api.BaseApi):
|
||||||
|
@ -21,8 +21,8 @@ from hamcrest import has_length
|
|||||||
|
|
||||||
from almanach.core import exception
|
from almanach.core import exception
|
||||||
from almanach.tests.unit.api import base_api
|
from almanach.tests.unit.api import base_api
|
||||||
from almanach.tests.unit.builder import a
|
from almanach.tests.unit.builders.entity import a
|
||||||
from almanach.tests.unit.builder import volume_type
|
from almanach.tests.unit.builders.entity import volume_type
|
||||||
|
|
||||||
|
|
||||||
class ApiVolumeTypeTest(base_api.BaseApi):
|
class ApiVolumeTypeTest(base_api.BaseApi):
|
||||||
|
@ -14,14 +14,10 @@
|
|||||||
|
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import pytz
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
import pytz
|
from almanach.core import model
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
class Builder(object):
|
class Builder(object):
|
||||||
@ -33,7 +29,7 @@ class Builder(object):
|
|||||||
class EntityBuilder(Builder):
|
class EntityBuilder(Builder):
|
||||||
|
|
||||||
def build(self):
|
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):
|
def with_id(self, entity_id):
|
||||||
self.dict_object["entity_id"] = entity_id
|
self.dict_object["entity_id"] = entity_id
|
||||||
@ -103,7 +99,7 @@ class VolumeBuilder(EntityBuilder):
|
|||||||
class VolumeTypeBuilder(Builder):
|
class VolumeTypeBuilder(Builder):
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
return VolumeType(**self.dict_object)
|
return model.VolumeType(**self.dict_object)
|
||||||
|
|
||||||
def with_volume_type_id(self, volume_type_id):
|
def with_volume_type_id(self, volume_type_id):
|
||||||
self.dict_object["volume_type_id"] = volume_type_id
|
self.dict_object["volume_type_id"] = volume_type_id
|
||||||
@ -127,7 +123,7 @@ def instance():
|
|||||||
"distro": "windows",
|
"distro": "windows",
|
||||||
"version": "2012r2"
|
"version": "2012r2"
|
||||||
},
|
},
|
||||||
"entity_type": Instance.TYPE,
|
"entity_type": model.Instance.TYPE,
|
||||||
"name": "some-instance",
|
"name": "some-instance",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"a_metadata.to_filter": "include.this",
|
"a_metadata.to_filter": "include.this",
|
||||||
@ -145,7 +141,7 @@ def volume():
|
|||||||
"last_event": datetime(2014, 1, 1, 0, 0, 0, 0, pytz.utc),
|
"last_event": datetime(2014, 1, 1, 0, 0, 0, 0, pytz.utc),
|
||||||
"volume_type": "SF400",
|
"volume_type": "SF400",
|
||||||
"size": 1000000,
|
"size": 1000000,
|
||||||
"entity_type": Volume.TYPE,
|
"entity_type": model.Volume.TYPE,
|
||||||
"name": "some-volume",
|
"name": "some-volume",
|
||||||
"attached_to": None,
|
"attached_to": None,
|
||||||
})
|
})
|
@ -25,9 +25,10 @@ import pytz
|
|||||||
from almanach.core.controllers import entity_controller
|
from almanach.core.controllers import entity_controller
|
||||||
from almanach.core import exception
|
from almanach.core import exception
|
||||||
from almanach.storage.drivers import base_driver
|
from almanach.storage.drivers import base_driver
|
||||||
|
|
||||||
from almanach.tests.unit import base
|
from almanach.tests.unit import base
|
||||||
from almanach.tests.unit.builder import a
|
from almanach.tests.unit.builders.entity import a
|
||||||
from almanach.tests.unit.builder import instance
|
from almanach.tests.unit.builders.entity import instance
|
||||||
|
|
||||||
|
|
||||||
class EntityControllerTest(base.BaseTestCase):
|
class EntityControllerTest(base.BaseTestCase):
|
||||||
|
@ -21,9 +21,10 @@ from almanach.core.controllers import instance_controller
|
|||||||
from almanach.core import exception
|
from almanach.core import exception
|
||||||
from almanach.core import model
|
from almanach.core import model
|
||||||
from almanach.storage.drivers import base_driver
|
from almanach.storage.drivers import base_driver
|
||||||
|
|
||||||
from almanach.tests.unit import base
|
from almanach.tests.unit import base
|
||||||
from almanach.tests.unit.builder import a
|
from almanach.tests.unit.builders.entity import a
|
||||||
from almanach.tests.unit.builder import instance
|
from almanach.tests.unit.builders.entity import instance
|
||||||
|
|
||||||
|
|
||||||
class InstanceControllerTest(base.BaseTestCase):
|
class InstanceControllerTest(base.BaseTestCase):
|
||||||
|
@ -22,10 +22,11 @@ from almanach.core.controllers import volume_controller
|
|||||||
from almanach.core import exception
|
from almanach.core import exception
|
||||||
from almanach.core import model
|
from almanach.core import model
|
||||||
from almanach.storage.drivers import base_driver
|
from almanach.storage.drivers import base_driver
|
||||||
|
|
||||||
from almanach.tests.unit import base
|
from almanach.tests.unit import base
|
||||||
from almanach.tests.unit.builder import a
|
from almanach.tests.unit.builders.entity import a
|
||||||
from almanach.tests.unit.builder import volume
|
from almanach.tests.unit.builders.entity import volume
|
||||||
from almanach.tests.unit.builder import volume_type
|
from almanach.tests.unit.builders.entity import volume_type
|
||||||
|
|
||||||
|
|
||||||
class VolumeControllerTest(base.BaseTestCase):
|
class VolumeControllerTest(base.BaseTestCase):
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from flexmock import flexmock
|
|
||||||
|
|
||||||
from almanach.core.controllers import volume_type_controller
|
from almanach.core.controllers import volume_type_controller
|
||||||
from almanach.storage.drivers import base_driver
|
from almanach.storage.drivers import base_driver
|
||||||
|
from flexmock import flexmock
|
||||||
|
|
||||||
from almanach.tests.unit import base
|
from almanach.tests.unit import base
|
||||||
from almanach.tests.unit.builder import a
|
from almanach.tests.unit.builders.entity import a
|
||||||
from almanach.tests.unit.builder import volume_type
|
from almanach.tests.unit.builders.entity import volume_type
|
||||||
|
|
||||||
|
|
||||||
class VolumeTypeControllerTest(base.BaseTestCase):
|
class VolumeTypeControllerTest(base.BaseTestCase):
|
||||||
|
@ -21,11 +21,12 @@ import pytz
|
|||||||
from almanach.core import exception
|
from almanach.core import exception
|
||||||
from almanach.core import model
|
from almanach.core import model
|
||||||
from almanach.storage.drivers import mongodb_driver
|
from almanach.storage.drivers import mongodb_driver
|
||||||
|
|
||||||
from almanach.tests.unit import base
|
from almanach.tests.unit import base
|
||||||
from almanach.tests.unit.builder import a
|
from almanach.tests.unit.builders.entity import a
|
||||||
from almanach.tests.unit.builder import instance
|
from almanach.tests.unit.builders.entity import instance
|
||||||
from almanach.tests.unit.builder import volume
|
from almanach.tests.unit.builders.entity import volume
|
||||||
from almanach.tests.unit.builder import volume_type
|
from almanach.tests.unit.builders.entity import volume_type
|
||||||
|
|
||||||
|
|
||||||
class MongoDbDriverTest(base.BaseTestCase):
|
class MongoDbDriverTest(base.BaseTestCase):
|
||||||
|
Loading…
Reference in New Issue
Block a user