本文整理汇总了Python中tests.builder.a函数的典型用法代码示例。如果您正苦于以下问题:Python a函数的具体用法?Python a怎么用?Python a使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了a函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_create_volume
def test_create_volume(self):
some_volume_type = a(volume_type().with_volume_type_name("some_volume_type_name"))
(flexmock(self.database_adapter)
.should_receive("get_volume_type")
.with_args(some_volume_type.volume_type_id)
.and_return(some_volume_type)
.once())
some_volume = a(volume()
.with_volume_type(some_volume_type.volume_type_name)
.with_all_dates_in_string())
expected_volume = a(volume()
.with_volume_type(some_volume_type.volume_type_name)
.with_project_id(some_volume.project_id)
.with_id(some_volume.entity_id))
(flexmock(self.database_adapter)
.should_receive("insert_entity")
.with_args(expected_volume)
.once())
(flexmock(self.database_adapter)
.should_receive("get_active_entity")
.with_args(some_volume.entity_id)
.and_return(None)
.once())
self.controller.create_volume(some_volume.entity_id, some_volume.project_id, some_volume.start,
some_volume_type.volume_type_id, some_volume.size, some_volume.name,
some_volume.attached_to)
开发者ID:mbelang,项目名称:almanach,代码行数:30,代码来源:test_controller.py
示例2: test_create_volume_with_invalid_volume_type
def test_create_volume_with_invalid_volume_type(self):
some_volume_type = a(volume_type())
(flexmock(self.database_adapter)
.should_receive("get_volume_type")
.with_args(some_volume_type.volume_type_id)
.and_raise(KeyError)
.once())
some_volume = a(volume()
.with_volume_type(some_volume_type.volume_type_name)
.with_all_dates_in_string())
(flexmock(self.database_adapter)
.should_receive("insert_entity")
.never())
(flexmock(self.database_adapter)
.should_receive("get_active_entity")
.with_args(some_volume.entity_id)
.and_return(None)
.once())
with self.assertRaises(KeyError):
self.controller.create_volume(some_volume.entity_id, some_volume.project_id, some_volume.start,
some_volume_type.volume_type_id, some_volume.size, some_volume.name,
some_volume.attached_to)
开发者ID:mbelang,项目名称:almanach,代码行数:25,代码来源:test_controller.py
示例3: test_list_volume_types
def test_list_volume_types(self):
fake_volume_types = [a(volume_type()), a(volume_type())]
for fake_volume_type in fake_volume_types:
self.db.volume_type.insert(todict(fake_volume_type))
self.assertEqual(len(self.adapter.list_volume_types()), 2)
开发者ID:internap,项目名称:almanach,代码行数:7,代码来源:test_database_adapter.py
示例4: test_volume_detach_last_attachment_after_threshold
def test_volume_detach_last_attachment_after_threshold(self):
fake_volume = a(volume().with_attached_to(["I1"]))
date = datetime(fake_volume.start.year, fake_volume.start.month, fake_volume.start.day, fake_volume.start.hour,
fake_volume.start.minute, fake_volume.start.second, fake_volume.start.microsecond)
date = date + timedelta(0, 120)
expected_date = pytz.utc.localize(date)
(flexmock(self.database_adapter)
.should_receive("get_active_entity")
.with_args(fake_volume.entity_id)
.and_return(fake_volume)
.once())
(flexmock(self.database_adapter)
.should_receive("close_active_entity")
.with_args(fake_volume.entity_id, expected_date)
.once())
new_volume = a(volume()
.build_from(fake_volume)
.with_datetime_start(expected_date)
.with_no_end()
.with_last_event(expected_date)
.with_no_attachment())
(flexmock(self.database_adapter)
.should_receive("insert_entity")
.with_args(new_volume)
.once())
self.controller.detach_volume(fake_volume.entity_id, date.strftime("%Y-%m-%dT%H:%M:%S.%f"), [])
self.assertEqual(fake_volume.attached_to, [])
开发者ID:mbelang,项目名称:almanach,代码行数:33,代码来源:test_controller.py
示例5: test_update_instance_flavor_for_terminated_instance
def test_update_instance_flavor_for_terminated_instance(self):
some_new_flavor = 'some_new_flavor'
data = dict(flavor=some_new_flavor)
start = '2016-03-01 00:00:00.000000'
end = '2016-03-03 00:00:00.000000'
self.controller.should_receive('update_inactive_entity') \
.with_args(
instance_id="INSTANCE_ID",
start=a_date_matching(start),
end=a_date_matching(end),
flavor=some_new_flavor,
).and_return(a(
instance().
with_id('INSTANCE_ID').
with_start(2016, 03, 01, 00, 0, 00).
with_end(2016, 03, 03, 00, 0, 00).
with_flavor(some_new_flavor))
)
code, result = self.api_put(
'/entity/instance/INSTANCE_ID',
headers={'X-Auth-Token': 'some token value'},
query_string={
'start': start,
'end': end,
},
data=data,
)
assert_that(code, equal_to(200))
assert_that(result, has_key('entity_id'))
assert_that(result, has_key('flavor'))
assert_that(result['flavor'], is_(some_new_flavor))
开发者ID:internap,项目名称:almanach,代码行数:33,代码来源:test_api_instance.py
示例6: test_list_volume_types
def test_list_volume_types(self):
some_volumes = [a(volume_type()), a(volume_type())]
(flexmock(self.database_adapter)
.should_receive("list_volume_types")
.and_return(some_volumes)
.once())
self.assertEqual(len(self.controller.list_volume_types()), 2)
开发者ID:mbelang,项目名称:almanach,代码行数:8,代码来源:test_controller.py
示例7: test_count_entities
def test_count_entities(self):
fake_active_entities = [
a(volume().with_id("id2").with_start(2014, 1, 1, 1, 0, 0).with_no_end()),
a(instance().with_id("id3").with_start(2014, 1, 1, 8, 0, 0).with_no_end()),
]
fake_inactive_entities = [
a(instance().with_id("id1").with_start(2014, 1, 1, 7, 0, 0).with_end(2014, 1, 1, 8, 0, 0)),
a(volume().with_id("id2").with_start(2014, 1, 1, 1, 0, 0).with_end(2014, 1, 1, 8, 0, 0)),
]
[self.db.entity.insert(todict(fake_entity)) for fake_entity in fake_active_entities + fake_inactive_entities]
self.assertEqual(4, self.adapter.count_entities())
self.assertEqual(2, self.adapter.count_active_entities())
self.assertEqual(1, self.adapter.count_entity_entries("id1"))
self.assertEqual(2, self.adapter.count_entity_entries("id2"))
开发者ID:internap,项目名称:almanach,代码行数:15,代码来源:test_database_adapter.py
示例8: test_insert_volume
def test_insert_volume(self):
count = self.db.entity.count()
fake_volume = a(volume())
self.adapter.insert_entity(fake_volume)
self.assertEqual(count + 1, self.db.entity.count())
self.assert_mongo_collection_contains("entity", fake_volume)
开发者ID:internap,项目名称:almanach,代码行数:7,代码来源:test_database_adapter.py
示例9: test_delete_volume_type
def test_delete_volume_type(self):
some_volume = a(volume_type())
(flexmock(self.database_adapter)
.should_receive("delete_volume_type")
.once())
self.controller.delete_volume_type(some_volume.volume_type_id)
开发者ID:mbelang,项目名称:almanach,代码行数:7,代码来源:test_controller.py
示例10: test_list_entities_by_id
def test_list_entities_by_id(self):
start = datetime(2016, 3, 1, 0, 0, 0, 0, pytz.utc)
end = datetime(2016, 3, 3, 0, 0, 0, 0, pytz.utc)
proper_instance = a(instance().with_id("id1").with_start(2016, 3, 1, 0, 0, 0).with_end(2016, 3, 2, 0, 0, 0))
instances = [
proper_instance,
a(instance()
.with_id("id1")
.with_start(2016, 3, 2, 0, 0, 0)
.with_no_end()),
]
[self.db.entity.insert(todict(fake_instance)) for fake_instance in instances]
instance_list = self.adapter.list_entities_by_id("id1", start, end)
assert_that(instance_list, contains_inanyorder(*[proper_instance]))
开发者ID:internap,项目名称:almanach,代码行数:16,代码来源:test_database_adapter.py
示例11: test_get_instance_entity_with_decode_output
def test_get_instance_entity_with_decode_output(self):
fake_entity = a(instance().with_metadata({"a_metadata_not_sanitize": "not.sanitize",
"a_metadata^to_sanitize": "this.sanitize"}))
self.db.entity.insert(todict(fake_entity))
entity = self.adapter.get_active_entity(fake_entity.entity_id)
expected_entity = a(instance()
.with_id(fake_entity.entity_id)
.with_project_id(fake_entity.project_id)
.with_metadata({"a_metadata_not_sanitize": "not.sanitize",
"a_metadata.to_sanitize": "this.sanitize"}))
self.assertEqual(entity, expected_entity)
self.assert_entities_metadata_have_been_sanitize([entity])
开发者ID:internap,项目名称:almanach,代码行数:16,代码来源:test_database_adapter.py
示例12: test_instance_rebuilded
def test_instance_rebuilded(self):
i = a(instance())
(flexmock(self.database_adapter)
.should_receive("get_active_entity")
.and_return(i)
.twice())
(flexmock(self.database_adapter)
.should_receive("close_active_entity")
.once())
(flexmock(self.database_adapter)
.should_receive("insert_entity")
.once())
self.controller.rebuild_instance(
"an_instance_id",
"some_distro",
"some_version",
"some_type",
"2015-10-21T16:25:00.000000Z"
)
self.controller.rebuild_instance(
"an_instance_id",
i.os.distro,
i.os.version,
i.os.os_type,
"2015-10-21T16:25:00.000000Z"
)
开发者ID:mbelang,项目名称:almanach,代码行数:28,代码来源:test_controller.py
示例13: test_update_active_entity
def test_update_active_entity(self):
fake_entity = a(instance())
end_date = datetime(2015, 10, 21, 16, 29, 0)
self.db.entity.insert(todict(fake_entity))
self.adapter.close_active_entity(fake_entity.entity_id, end_date)
self.assertEqual(self.db.entity.find_one({"entity_id": fake_entity.entity_id})["end"], end_date)
开发者ID:internap,项目名称:almanach,代码行数:8,代码来源:test_database_adapter.py
示例14: test_get_instance_entity_with_unknown_type
def test_get_instance_entity_with_unknown_type(self):
fake_entity = a(instance())
fake_entity.entity_type = "will_raise_excepion"
self.db.entity.insert(todict(fake_entity))
with self.assertRaises(NotImplementedError):
self.adapter.get_active_entity(fake_entity.entity_id)
开发者ID:internap,项目名称:almanach,代码行数:8,代码来源:test_database_adapter.py
示例15: test_delete_active_entity
def test_delete_active_entity(self):
fake_entity = a(volume())
self.db.entity.insert(todict(fake_entity))
self.assertEqual(1, self.db.entity.count())
self.adapter.delete_active_entity(fake_entity.entity_id)
self.assertEqual(0, self.db.entity.count())
开发者ID:internap,项目名称:almanach,代码行数:8,代码来源:test_database_adapter.py
示例16: test_volume_type_created
def test_volume_type_created(self):
fake_volume_type = a(volume_type())
(flexmock(self.database_adapter)
.should_receive("insert_volume_type")
.with_args(fake_volume_type)
.once())
self.controller.create_volume_type(fake_volume_type.volume_type_id, fake_volume_type.volume_type_name)
开发者ID:mbelang,项目名称:almanach,代码行数:9,代码来源:test_controller.py
示例17: test_rename_volume
def test_rename_volume(self):
fake_volume = a(volume().with_display_name('old_volume_name'))
volume_name = 'new_volume_name'
(flexmock(self.database_adapter)
.should_receive("get_active_entity")
.with_args(fake_volume.entity_id)
.and_return(fake_volume)
.once())
new_volume = a(volume().build_from(fake_volume).with_display_name(volume_name))
(flexmock(self.database_adapter)
.should_receive("update_active_entity")
.with_args(new_volume)
.once())
self.controller.rename_volume(fake_volume.entity_id, volume_name)
开发者ID:mbelang,项目名称:almanach,代码行数:19,代码来源:test_controller.py
示例18: test_replace_entity
def test_replace_entity(self):
fake_entity = a(instance())
fake_entity.os.distro = "Centos"
self.db.entity.insert(todict(fake_entity))
fake_entity.os.distro = "Windows"
self.adapter.update_active_entity(fake_entity)
self.assertEqual(self.db.entity.find_one({"entity_id": fake_entity.entity_id})["os"]["distro"], fake_entity.os.distro)
开发者ID:Marx314,项目名称:almanach,代码行数:10,代码来源:test_database_adapter.py
示例19: test_create_volume_but_its_an_old_event
def test_create_volume_but_its_an_old_event(self):
some_volume = a(volume().with_last_event(pytz.utc.localize(datetime(2015, 10, 21, 16, 29, 0))))
(flexmock(self.database_adapter)
.should_receive("get_active_entity")
.with_args(some_volume.entity_id)
.and_return(some_volume)
.once())
self.controller.create_volume(some_volume.entity_id, some_volume.project_id, '2015-10-21T16:25:00.000000Z',
some_volume.volume_type, some_volume.size, some_volume.name, some_volume.attached_to)
开发者ID:mbelang,项目名称:almanach,代码行数:10,代码来源:test_controller.py
示例20: test_get_entity
def test_get_entity(self):
fake_entity = a(instance().with_id("id1").with_start(2014, 1, 1, 8, 0, 0).with_no_end())
self.db.entity.insert(todict(fake_entity))
entries = self.adapter.get_all_entities_by_id(entity_id="id1")
self.assertEqual(1, len(entries))
self.assertEqual("id1", entries[0].entity_id)
entries = self.adapter.get_all_entities_by_id(entity_id="id2")
self.assertEqual(0, len(entries))
开发者ID:internap,项目名称:almanach,代码行数:10,代码来源:test_database_adapter.py
注:本文中的tests.builder.a函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论