本文整理汇总了Python中unittest.mock.Mock.ruletype方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.ruletype方法的具体用法?Python Mock.ruletype怎么用?Python Mock.ruletype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.mock.Mock
的用法示例。
在下文中一共展示了Mock.ruletype方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_146_weight_wrong_rule_type
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import ruletype [as 别名]
def test_146_weight_wrong_rule_type(self):
"""PermMap get weight of rule with wrong rule type."""
rule = Mock()
rule.ruletype = "type_transition"
rule.tclass = "infoflow"
permmap = PermissionMap("tests/perm_map")
self.assertRaises(RuleTypeError, permmap.rule_weight, rule)
示例2: test_144_weight_unmapped_class
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import ruletype [as 别名]
def test_144_weight_unmapped_class(self):
"""PermMap get weight of rule with unmapped class."""
rule = Mock()
rule.ruletype = "allow"
rule.tclass = "unmapped"
rule.perms = set(["null"])
permmap = PermissionMap("tests/perm_map")
self.assertRaises(UnmappedClass, permmap.rule_weight, rule)
示例3: test_145_weight_unmapped_permission
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import ruletype [as 别名]
def test_145_weight_unmapped_permission(self):
"""PermMap get weight of rule with unmapped permission."""
rule = Mock()
rule.ruletype = "allow"
rule.tclass = "infoflow"
rule.perms = set(["low_r", "unmapped"])
permmap = PermissionMap("tests/perm_map")
self.assertRaises(UnmappedPermission, permmap.rule_weight, rule)
示例4: test_143_weight_none
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import ruletype [as 别名]
def test_143_weight_none(self):
"""PermMap get weight of none rule."""
rule = Mock()
rule.ruletype = "allow"
rule.tclass = "infoflow3"
rule.perms = set(["null"])
permmap = PermissionMap("tests/perm_map")
r, w = permmap.rule_weight(rule)
self.assertEqual(r, 0)
self.assertEqual(w, 0)
示例5: test_142_weight_both
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import ruletype [as 别名]
def test_142_weight_both(self):
"""PermMap get weight of both rule."""
rule = Mock()
rule.ruletype = "allow"
rule.tclass = "infoflow"
rule.perms = set(["low_r", "hi_w"])
permmap = PermissionMap("tests/perm_map")
r, w = permmap.rule_weight(rule)
self.assertEqual(r, 1)
self.assertEqual(w, 10)
示例6: test_141_weight_write_only
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import ruletype [as 别名]
def test_141_weight_write_only(self):
"""PermMap get weight of write-only rule."""
rule = Mock()
rule.ruletype = "allow"
rule.tclass = "infoflow"
rule.perms = set(["low_w", "med_w"])
permmap = PermissionMap("tests/perm_map")
r, w = permmap.rule_weight(rule)
self.assertEqual(r, 0)
self.assertEqual(w, 5)
示例7: test_140_weight_read_only
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import ruletype [as 别名]
def test_140_weight_read_only(self):
"""PermMap get weight of read-only rule."""
rule = Mock()
rule.ruletype = "allow"
rule.tclass = "infoflow"
rule.perms = set(["med_r", "hi_r"])
permmap = PermissionMap("tests/perm_map")
r, w = permmap.rule_weight(rule)
self.assertEqual(r, 10)
self.assertEqual(w, 0)
示例8: test_148_weight_excluded_class
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import ruletype [as 别名]
def test_148_weight_excluded_class(self):
"""PermMap get weight of a rule with excluded class."""
rule = Mock()
rule.ruletype = "allow"
rule.tclass = "infoflow"
rule.perms = set(["low_r", "med_r", "hi_r", "low_w", "med_w", "hi_w"])
permmap = PermissionMap("tests/perm_map")
permmap.exclude_class("infoflow")
r, w = permmap.rule_weight(rule)
self.assertEqual(r, 0)
self.assertEqual(w, 0)
示例9: test_147_weight_excluded_permission
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import ruletype [as 别名]
def test_147_weight_excluded_permission(self):
"""PermMap get weight of a rule with excluded permission."""
rule = Mock()
rule.ruletype = TERuletype.allow
rule.tclass = "infoflow"
rule.perms = set(["med_r", "hi_r"])
permmap = PermissionMap("tests/perm_map")
permmap.exclude_permission("infoflow", "hi_r")
r, w = permmap.rule_weight(rule)
self.assertEqual(r, 5)
self.assertEqual(w, 0)