当前位置: 首页>>代码示例>>Python>>正文


Python Mock.tclass方法代码示例

本文整理汇总了Python中unittest.mock.Mock.tclass方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.tclass方法的具体用法?Python Mock.tclass怎么用?Python Mock.tclass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unittest.mock.Mock的用法示例。


在下文中一共展示了Mock.tclass方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_146_weight_wrong_rule_type

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import tclass [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)
开发者ID:GitForNeo,项目名称:setools,代码行数:10,代码来源:permmap.py

示例2: test_144_weight_unmapped_class

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import tclass [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)
开发者ID:GitForNeo,项目名称:setools,代码行数:11,代码来源:permmap.py

示例3: test_145_weight_unmapped_permission

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import tclass [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)
开发者ID:GitForNeo,项目名称:setools,代码行数:11,代码来源:permmap.py

示例4: test_143_weight_none

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import tclass [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)
开发者ID:GitForNeo,项目名称:setools,代码行数:13,代码来源:permmap.py

示例5: test_142_weight_both

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import tclass [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)
开发者ID:GitForNeo,项目名称:setools,代码行数:13,代码来源:permmap.py

示例6: test_141_weight_write_only

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import tclass [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)
开发者ID:GitForNeo,项目名称:setools,代码行数:13,代码来源:permmap.py

示例7: test_140_weight_read_only

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import tclass [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)
开发者ID:GitForNeo,项目名称:setools,代码行数:13,代码来源:permmap.py

示例8: test_148_weight_excluded_class

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import tclass [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)
开发者ID:GitForNeo,项目名称:setools,代码行数:14,代码来源:permmap.py

示例9: test_147_weight_excluded_permission

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import tclass [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)
开发者ID:TresysTechnology,项目名称:setools,代码行数:14,代码来源:permmap.py


注:本文中的unittest.mock.Mock.tclass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。