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


Python Mock.level方法代码示例

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


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

示例1: it_creates_items

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import level [as 别名]
    def it_creates_items(self, time, generate_id):
        generate_id.return_value = 'random'
        time.return_value = 1400000000.00

        key3 = Mock()
        key3.identifier = 'abcd'
        key3.level = 'SL3'

        key5 = Mock()
        key5.identifier = 'efgh'
        key5.level = 'SL5'

        data_source = DataSource('some_path')
        data_source._keys = [key3, key5]

        item = data_source.create_item()

        assert type(item) is AgileKeychainItem
        assert item['uuid'] == 'random'
        assert item['createdAt'] == 1400000000
        assert item['location'] == ''
        assert item['locationKey'] == ''
        assert item['title'] == 'Untitled'
        assert item['typeName'] == 'passwords.Password'
        assert item['keyID'] == 'efgh'
        assert item['encrypted'] == {}
开发者ID:clofresh,项目名称:blimey,代码行数:28,代码来源:data_source_spec.py

示例2: test_issues_duplicate_level

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import level [as 别名]
 def test_issues_duplicate_level(self):
     """Verify duplicate item levels are detected."""
     mock_item1 = Mock()
     mock_item1.uid = 'HLT001'
     mock_item1.level = Level('4.2')
     mock_item2 = Mock()
     mock_item2.uid = 'HLT002'
     mock_item2.level = Level('4.2')
     mock_items = [mock_item1, mock_item2]
     expected = DoorstopWarning("duplicate level: 4.2 (HLT001, HLT002)")
     issue = list(self.document._get_issues_level(mock_items))[0]
     self.assertIsInstance(issue, type(expected))
     self.assertEqual(expected.args, issue.args)
开发者ID:elewis33,项目名称:doorstop,代码行数:15,代码来源:test_document.py

示例3: test_issues_skipped_level_out_over

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import level [as 别名]
 def test_issues_skipped_level_out_over(self):
     """Verify skipped (out and over) item levels are detected."""
     mock_item1 = Mock()
     mock_item1.uid = 'HLT001'
     mock_item1.level = Level('1.1')
     mock_item2 = Mock()
     mock_item2.uid = 'HLT002'
     mock_item2.level = Level('2.2')
     mock_items = [mock_item1, mock_item2]
     expected = DoorstopWarning("skipped level: 1.1 (HLT001), 2.2 (HLT002)")
     issues = list(self.document._get_issues_level(mock_items))
     self.assertEqual(1, len(issues))
     self.assertIsInstance(issues[0], type(expected))
     self.assertEqual(expected.args, issues[0].args)
开发者ID:elewis33,项目名称:doorstop,代码行数:16,代码来源:test_document.py

示例4: it_guarantees_generated_item_id_is_unique

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import level [as 别名]
    def it_guarantees_generated_item_id_is_unique(self, generate_id, get_item_by_id):
        get_item_by_id.side_effect = [Mock(), ItemNotFoundException]
        generate_id.side_effect = ['123', '567']

        key3 = Mock()
        key3.identifier = 'abcd'
        key3.level = 'SL3'

        key5 = Mock()
        key5.identifier = 'efgh'
        key5.level = 'SL5'

        data_source = DataSource('some_path')
        data_source._keys = [key3, key5]

        item = data_source.create_item()

        assert item['uuid'] == '567'
开发者ID:clofresh,项目名称:blimey,代码行数:20,代码来源:data_source_spec.py

示例5: it_creates_items_item_initialised_with_data

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import level [as 别名]
    def it_creates_items_item_initialised_with_data(self, generate_id):
        generate_id.return_value = 'random'

        key3 = Mock()
        key3.identifier = 'abcd'
        key3.level = 'SL3'

        key5 = Mock()
        key5.identifier = 'efgh'
        key5.level = 'SL5'

        data_source = DataSource('some_path')
        data_source._keys = [key3, key5]

        item = data_source.create_item({'title': 'Thing'})

        assert type(item) is AgileKeychainItem
        assert item['title'] == 'Thing'
开发者ID:clofresh,项目名称:blimey,代码行数:20,代码来源:data_source_spec.py

示例6: test_add_item_after_header

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import level [as 别名]
 def test_add_item_after_header(self, mock_new):
     """Verify the next item after a header is indented."""
     mock_item = Mock()
     mock_item.number = 1
     mock_item.level = Level('1.0')
     self.document._iter = Mock(return_value=[mock_item])
     self.document.add_item()
     mock_new.assert_called_once_with(None, self.document,
                                      FILES, ROOT, 'REQ002',
                                      level=Level('1.1'))
开发者ID:elewis33,项目名称:doorstop,代码行数:12,代码来源:test_document.py

示例7: test_pass_satisfied

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import level [as 别名]
 def test_pass_satisfied(self):
     # Check that error isn't raised when all skill requirements
     # are met
     item = self.ch.type_(type_id=1)
     item.required_skills = {50: 3}
     holder = Mock(state=State.offline, item=item, _domain=Domain.ship, spec_set=ModuleHigh(1))
     self.track_holder(holder)
     skill_item = self.ch.type_(type_id=50)
     skill_holder = Mock(state=State.offline, item=skill_item, _domain=Domain.character, spec_set=Skill(1))
     skill_holder.level = 3
     self.track_holder(skill_holder)
     self.fit.skills[50] = skill_holder
     restriction_error = self.get_restriction_error(holder, Restriction.skill_requirement)
     self.assertIsNone(restriction_error)
     self.untrack_holder(holder)
     self.untrack_holder(skill_holder)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
开发者ID:blitzmann,项目名称:Eos,代码行数:20,代码来源:test_skill_requirement.py

示例8: test_fail_multiple

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import level [as 别名]
 def test_fail_multiple(self):
     # Check that multiple errors are shown as iterable
     item = self.ch.type_(type_id=1)
     item.required_skills = {48: 1, 50: 5}
     holder = Mock(state=State.offline, item=item, _domain=Domain.ship, spec_set=ModuleHigh(1))
     self.track_holder(holder)
     skill_item = self.ch.type_(type_id=50)
     skill_holder = Mock(state=State.offline, item=skill_item, _domain=Domain.character, spec_set=Skill(1))
     skill_holder.level = 2
     self.track_holder(skill_holder)
     self.fit.skills[50] = skill_holder
     restriction_error = self.get_restriction_error(holder, Restriction.skill_requirement)
     self.assertIsNotNone(restriction_error)
     self.assertCountEqual(restriction_error, ((50, 2, 5), (48, None, 1)))
     self.untrack_holder(holder)
     self.untrack_holder(skill_holder)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
开发者ID:blitzmann,项目名称:Eos,代码行数:20,代码来源:test_skill_requirement.py

示例9: test_fail_partial

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import level [as 别名]
 def test_fail_partial(self):
     # Make sure satisfied skill requirements are not shown
     # up in error
     item = self.ch.type_(type_id=1)
     item.required_skills = {48: 1, 50: 5}
     holder = Mock(state=State.offline, item=item, _domain=Domain.ship, spec_set=ModuleHigh(1))
     self.track_holder(holder)
     skill_item = self.ch.type_(type_id=48)
     skill_holder = Mock(state=State.offline, item=skill_item, _domain=Domain.character, spec_set=Skill(1))
     skill_holder.level = 5
     self.track_holder(skill_holder)
     self.fit.skills[48] = skill_holder
     restriction_error = self.get_restriction_error(holder, Restriction.skill_requirement)
     self.assertIsNotNone(restriction_error)
     self.assertCountEqual(restriction_error, ((50, None, 5),))
     self.untrack_holder(holder)
     self.untrack_holder(skill_holder)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
开发者ID:blitzmann,项目名称:Eos,代码行数:21,代码来源:test_skill_requirement.py

示例10: test_run

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import level [as 别名]
    def test_run(self, *args):
        """Test md format populator."""
        get_device_by_uuid = args[0]
        get_devices = args[1]
        device_is_md = args[2]

        devicetree = DeviceTree()
        data = dict()
        device = Mock()
        device.name = sentinel.dev1_name
        device.parents = []
        device.size = Size("10g")
        devicetree._add_device(device)

        # pylint: disable=attribute-defined-outside-init
        self._examine = blockdev.md.examine
        blockdev.md.examine = Mock()
        self.addCleanup(self._clean_up)

        # member belongs to a valid array which is already in the tree
        md_info = Mock()
        md_info.uuid = sentinel.md_uuid
        blockdev.md.examine.return_value = md_info

        md_device = Mock()
        get_device_by_uuid.return_value = md_device

        with patch("blivet.udev.device_get_format", return_value=self.udev_type):
            helper = self.helper_class(devicetree, data, device)
            helper.run()
            self.assertEqual(device.format.type,
                             self.blivet_type,
                             msg="Wrong format type after FormatPopulator.run on %s" % self.udev_type)

            self.assertEqual(get_device_by_uuid.call_count, 1)
            get_device_by_uuid.assert_called_with(md_info.uuid, incomplete=True)
            md_device.parents.append.assert_called_once_with(device)  # pylint: disable=no-member

        get_device_by_uuid.reset_mock()
        get_device_by_uuid.return_value = None

        # first of two members belonging to a valid array which is not in the tree
        array_name = "mdtest"
        md_info.level = "raid1"
        md_info.num_devices = 2
        md_info.metadata = "1.2"
        md_info.device = "/dev/md/" + array_name
        blockdev.md.examine.return_value = md_info

        device_is_md.return_value = True
        md_udev = {"MD_LEVEL": md_info.level, "MD_UUID": sentinel.md_uuid, "MD_DEVNAME": array_name}
        get_devices.return_value = [md_udev]

        with patch("blivet.udev.device_get_format", return_value=self.udev_type):
            helper = self.helper_class(devicetree, data, device)
            helper.run()
            self.assertEqual(device.format.type,
                             self.blivet_type,
                             msg="Wrong format type after FormatPopulator.run on %s" % self.udev_type)

            self.assertEqual(get_device_by_uuid.call_count, 1)
            get_device_by_uuid.assert_called_with(md_info.uuid, incomplete=True)
            array = devicetree.get_device_by_name(array_name)
            self.assertTrue(array is None)
            array = devicetree.get_device_by_name(array_name, incomplete=True)
            self.assertTrue(array is not None)
            self.assertFalse(array.complete)
            self.assertEqual(array.name, array_name)

        get_device_by_uuid.reset_mock()
        array = devicetree.get_device_by_name(array_name, incomplete=True)
        get_device_by_uuid.return_value = array

        # second of two members belonging to a valid array
        device2 = Mock()
        device2.name = sentinel.dev2_name
        device2.parents = []
        device2.size = Size("10g")
        devicetree._add_device(device2)

        with patch("blivet.udev.device_get_format", return_value=self.udev_type):
            helper = self.helper_class(devicetree, data, device2)
            helper.run()
            self.assertEqual(device2.format.type,
                             self.blivet_type,
                             msg="Wrong format type after FormatPopulator.run on %s" % self.udev_type)

            self.assertEqual(get_device_by_uuid.call_count, 1)  # one for the array
            get_device_by_uuid.assert_called_with(md_info.uuid, incomplete=True)

            array = devicetree.get_device_by_name(array_name)
            self.assertTrue(array is not None)
            self.assertTrue(array.complete)
            self.assertEqual(array.name, array_name)
开发者ID:afamilyman,项目名称:blivet,代码行数:96,代码来源:populator_test.py


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