本文整理匯總了Python中hamcrest.is_方法的典型用法代碼示例。如果您正苦於以下問題:Python hamcrest.is_方法的具體用法?Python hamcrest.is_怎麽用?Python hamcrest.is_使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類hamcrest
的用法示例。
在下文中一共展示了hamcrest.is_方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_raised_exceptions_are_marshalled_correctly
# 需要導入模塊: import hamcrest [as 別名]
# 或者: from hamcrest import is_ [as 別名]
def test_raised_exceptions_are_marshalled_correctly(self):
self.switch_factory.should_receive('get_switch').with_args('my.switch').and_return(self.switch_mock).once().ordered()
self.switch_mock.should_receive('connect').once().ordered()
self.switch_mock.should_receive('set_access_vlan').with_args('FastEthernet0/4', 1000).once().ordered() \
.and_raise(UnknownInterface("SHIZZLE"))
self.switch_mock.should_receive('disconnect').once().ordered()
result, code = self.put("/switches/my.switch/interfaces/FastEthernet0/4/access-vlan",
fixture="put_switch_hostname_interfaces_intname_accessvlan.txt",
headers={"Netman-Verbose-Errors": "yes"})
assert_that(code, is_(404))
assert_that(result, is_({
"error": "Unknown interface SHIZZLE",
"error-module": UnknownInterface.__module__,
"error-class": UnknownInterface.__name__,
}))
示例2: test_raised_base_exceptions_are_marshalled_correctly
# 需要導入模塊: import hamcrest [as 別名]
# 或者: from hamcrest import is_ [as 別名]
def test_raised_base_exceptions_are_marshalled_correctly(self):
self.switch_factory.should_receive('get_switch').with_args('my.switch').and_return(self.switch_mock).once().ordered()
self.switch_mock.should_receive('connect').once().ordered()
self.switch_mock.should_receive('set_access_vlan').with_args('FastEthernet0/4', 1000).once().ordered() \
.and_raise(Exception("ERMAHGERD"))
self.switch_mock.should_receive('disconnect').once().ordered()
result, code = self.put("/switches/my.switch/interfaces/FastEthernet0/4/access-vlan",
fixture="put_switch_hostname_interfaces_intname_accessvlan.txt",
headers={"Netman-Verbose-Errors": "yes"})
assert_that(code, is_(500))
assert_that(result, is_({
"error": "ERMAHGERD",
"error-class": "Exception",
}))
示例3: test_raised_not_implemented_error_are_marshalled_correctly
# 需要導入模塊: import hamcrest [as 別名]
# 或者: from hamcrest import is_ [as 別名]
def test_raised_not_implemented_error_are_marshalled_correctly(self):
self.switch_factory.should_receive('get_switch').with_args('my.switch').and_return(self.switch_mock).once().ordered()
self.switch_mock.should_receive('connect').once().ordered()
self.switch_mock.should_receive('set_access_vlan').with_args('FastEthernet0/4', 1000).once().ordered() \
.and_raise(NotImplementedError())
self.switch_mock.should_receive('disconnect').once().ordered()
result, code = self.put("/switches/my.switch/interfaces/FastEthernet0/4/access-vlan",
fixture="put_switch_hostname_interfaces_intname_accessvlan.txt",
headers={"Netman-Verbose-Errors": "yes"})
assert_that(code, is_(501))
assert_that(result, is_({
"error": "",
"error-class": "NotImplementedError",
}))
示例4: test_get_interface_and_get_interfaces_are_same
# 需要導入模塊: import hamcrest [as 別名]
# 或者: from hamcrest import is_ [as 別名]
def test_get_interface_and_get_interfaces_are_same(self):
self.client.add_vlan(1000, name="vlan1000")
self.client.add_vlan(2000, name="vlan2000")
expected = self.test_ports[0]
self.try_to.set_access_vlan(expected.name, 1000)
self.try_to.set_trunk_mode(expected.name)
self.try_to.set_interface_state(expected.name, ON)
self.try_to.set_interface_native_vlan(expected.name, 2000)
self.try_to.set_interface_auto_negotiation_state(expected.name, ON)
self.try_to.set_interface_mtu(expected.name, 5000)
interface_from_single = self.client.get_interface(expected.name)
interfaces = [inte for inte in self.client.get_interfaces() if inte.name == expected.name]
interface_from_multiple = interfaces[0]
assert_that(interface_from_single.name, is_(interface_from_multiple.name))
assert_that(interface_from_single.port_mode, is_(interface_from_multiple.port_mode))
assert_that(interface_from_single.shutdown, is_(interface_from_multiple.shutdown))
assert_that(interface_from_single.trunk_native_vlan, is_(interface_from_multiple.trunk_native_vlan))
assert_that(interface_from_single.trunk_vlans, is_(interface_from_multiple.trunk_vlans))
assert_that(interface_from_single.auto_negotiation, is_(interface_from_multiple.auto_negotiation))
assert_that(interface_from_single.mtu, is_(interface_from_multiple.mtu))
示例5: test_get_vlan_with_an_empty_interface
# 需要導入模塊: import hamcrest [as 別名]
# 或者: from hamcrest import is_ [as 別名]
def test_get_vlan_with_an_empty_interface(self):
self.shell_mock.should_receive("do").with_args("show vlan 1750").once().ordered().and_return(
vlan_with_vif_display(1750, 999, name="Shizzle")
)
self.shell_mock.should_receive("do").with_args("show running-config interface ve 999").once().ordered().and_return([
"interface ve 999",
"!",
])
vlan = self.switch.get_vlan(1750)
assert_that(vlan.number, is_(1750))
assert_that(vlan.name, is_("Shizzle"))
assert_that(vlan.access_groups[IN], is_(none()))
assert_that(vlan.access_groups[OUT], is_(none()))
assert_that(vlan.vrf_forwarding, is_(none()))
assert_that(vlan.ips, is_(empty()))
assert_that(vlan.vrrp_groups, is_(empty()))
assert_that(vlan.dhcp_relay_servers, is_(empty()))
示例6: test_after_get_vlans_was_cached_adding_new_vlans_will_trigger_single_get_vlans_to_fill_the_gaps
# 需要導入模塊: import hamcrest [as 別名]
# 或者: from hamcrest import is_ [as 別名]
def test_after_get_vlans_was_cached_adding_new_vlans_will_trigger_single_get_vlans_to_fill_the_gaps(self):
all_vlans = [Vlan(1)]
self.real_switch_mock.should_receive("get_vlans").once().ordered().and_return(all_vlans)
assert_that(self.switch.get_vlans(), is_(all_vlans))
self.real_switch_mock.should_receive("add_vlan").once().with_args(10)
self.switch.add_vlan(10)
self.real_switch_mock.should_receive("add_vlan").once().with_args(11)
self.switch.add_vlan(11)
self.real_switch_mock.should_receive("add_vlan").once().with_args(12)
self.switch.add_vlan(12)
self.real_switch_mock.should_receive("get_vlan").with_args(10).once().and_return(Vlan(10))
self.real_switch_mock.should_receive("get_vlan").with_args(11).once().and_return(Vlan(11))
self.real_switch_mock.should_receive("get_vlan").with_args(12).once().and_return(Vlan(12))
assert_that(self.switch.get_vlans(), is_([Vlan(1), Vlan(10), Vlan(11), Vlan(12)]))
assert_that(self.switch.get_vlans(), is_([Vlan(1), Vlan(10), Vlan(11), Vlan(12)]))
示例7: check_current_state
# 需要導入模塊: import hamcrest [as 別名]
# 或者: from hamcrest import is_ [as 別名]
def check_current_state(context, state_name):
assert_that(context.current_state.label, is_(state_name))
示例8: test_shouldInjectTheField
# 需要導入模塊: import hamcrest [as 別名]
# 或者: from hamcrest import is_ [as 別名]
def test_shouldInjectTheField(self): # pylint: disable=no-self-use
assert_that(BasicTestModel, has_property('river', is_(instance_of(RiverObject))))
assert_that(BasicTestModel.river, has_property('my_field', is_(instance_of(ClassWorkflowObject))))
content_type = ContentType.objects.get_for_model(BasicTestModel)
state1 = StateObjectFactory.create(label="state1")
state2 = StateObjectFactory.create(label="state2")
workflow = WorkflowFactory(content_type=content_type, field_name="my_field", initial_state=state1)
transition_meta = TransitionMetaFactory.create(
workflow=workflow,
source_state=state1,
destination_state=state2,
)
TransitionApprovalMetaFactory.create(
workflow=workflow,
transition_meta=transition_meta,
priority=0
)
test_model = BasicTestModel.objects.create()
assert_that(test_model, has_property('river', is_(instance_of(RiverObject))))
assert_that(test_model.river, has_property('my_field', is_(instance_of(InstanceWorkflowObject))))
assert_that(BasicTestModel.river.my_field, has_property('initial_state', is_(instance_of(State))))
assert_that(BasicTestModel.river.my_field, has_property('final_states', is_(instance_of(QuerySet))))
assert_that(test_model.river.my_field, has_property('approve', has_property("__call__")))
assert_that(test_model.river.my_field, has_property('on_initial_state', is_(instance_of(bool))))
assert_that(test_model.river.my_field, has_property('on_final_state', is_(instance_of(bool))))
示例9: ensure_device_specific_skill_removed
# 需要導入模塊: import hamcrest [as 別名]
# 或者: from hamcrest import is_ [as 別名]
def ensure_device_specific_skill_removed(context):
skill_repo = SkillRepository(context.db)
skill = skill_repo.get_skill_by_global_id(
context.device_specific_skill.skill_gid
)
assert_that(skill, is_(none()))
示例10: get_new_skill
# 需要導入模塊: import hamcrest [as 別名]
# 或者: from hamcrest import is_ [as 別名]
def get_new_skill(context):
skill_repo = SkillRepository(context.db)
skill = skill_repo.get_skill_by_global_id(
context.new_skill.skill_gid
)
assert_that(skill, is_(not_none()))
示例11: test_legacy_token
# 需要導入模塊: import hamcrest [as 別名]
# 或者: from hamcrest import is_ [as 別名]
def test_legacy_token(self, legacy_file_path, config_file_path):
assert_that(path.isfile(config_file_path), is_(False))
config = FileConfig(legacy_file_path=legacy_file_path,
config_file_path=config_file_path)
assert_that(config.auth_token, equal_to('legacyabcd'))
assert_that(path.isfile(config_file_path), is_(True))
示例12: test_missing_file
# 需要導入模塊: import hamcrest [as 別名]
# 或者: from hamcrest import is_ [as 別名]
def test_missing_file(self, config_file_path):
assert_that(path.isfile(config_file_path), is_(False))
config = FileConfig(config_file_path=config_file_path)
assert_that(calling(lambda: config.auth_token), raises(RuntimeError))
示例13: test_missing_file_unsuitable_legacy_file
# 需要導入模塊: import hamcrest [as 別名]
# 或者: from hamcrest import is_ [as 別名]
def test_missing_file_unsuitable_legacy_file(self, config_file_path):
assert_that(path.isfile(config_file_path), is_(False))
config = FileConfig(config_file_path=config_file_path)
assert_that(calling(lambda: config.auth_token), raises(RuntimeError))
示例14: test_missing_token
# 需要導入模塊: import hamcrest [as 別名]
# 或者: from hamcrest import is_ [as 別名]
def test_missing_token(self, config_file_path):
assert_that(path.isfile(config_file_path), is_(True))
config = FileConfig(profile='missingprofile',
config_file_path=config_file_path)
assert_that(calling(lambda: config.auth_token), raises(RuntimeError))
示例15: test_save
# 需要導入模塊: import hamcrest [as 別名]
# 或者: from hamcrest import is_ [as 別名]
def test_save(self, config_file_path):
assert_that(path.isfile(config_file_path), is_(False))
config = FileConfig(config_file_path=config_file_path)
config.auth_token = 'brandnewtoken'
config.save()
config_reload = FileConfig(config_file_path=config_file_path)
assert_that(path.isfile(config_file_path), is_(True))
assert_that(config_reload.auth_token, equal_to(config.auth_token))