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


Python ConsumerHistoryEvent.get_collection方法代码示例

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


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

示例1: record_event

# 需要导入模块: from pulp.server.db.model.consumer import ConsumerHistoryEvent [as 别名]
# 或者: from pulp.server.db.model.consumer.ConsumerHistoryEvent import get_collection [as 别名]
    def record_event(self, consumer_id, event_type, event_details=None):
        """
        @ivar consumer_id: identifies the consumer
        @type id: str

        @param type: event type
        @type type: str

        @param details: event details
        @type details: dict

        @raises MissingResource: if the given consumer does not exist
        @raises InvalidValue: if any of the fields is unacceptable
        """
        # Check that consumer exists for all except registration event
        existing_consumer = Consumer.get_collection().find_one({'id': consumer_id})
        if not existing_consumer and event_type != TYPE_CONSUMER_UNREGISTERED:
            raise MissingResource(consumer=consumer_id)

        invalid_values = []
        if event_type not in TYPES:
            invalid_values.append('event_type')

        if event_details is not None and not isinstance(event_details, dict):
            invalid_values.append('event_details')

        if invalid_values:
            raise InvalidValue(invalid_values)

        event = ConsumerHistoryEvent(consumer_id, self._originator(), event_type, event_details)
        ConsumerHistoryEvent.get_collection().save(event)
开发者ID:jeremycline,项目名称:pulp,代码行数:33,代码来源:history.py

示例2: tearDown

# 需要导入模块: from pulp.server.db.model.consumer import ConsumerHistoryEvent [as 别名]
# 或者: from pulp.server.db.model.consumer.ConsumerHistoryEvent import get_collection [as 别名]
 def tearDown(self):
     super(BindManagerTests, self).tearDown()
     Consumer.get_collection().remove()
     model.Repository.objects.delete()
     model.Distributor.objects.delete()
     Bind.get_collection().remove()
     ConsumerHistoryEvent.get_collection().remove()
     mock_plugins.reset()
开发者ID:alanoe,项目名称:pulp,代码行数:10,代码来源:test_bind.py

示例3: setUp

# 需要导入模块: from pulp.server.db.model.consumer import ConsumerHistoryEvent [as 别名]
# 或者: from pulp.server.db.model.consumer.ConsumerHistoryEvent import get_collection [as 别名]
 def setUp(self):
     super(BindManagerTests, self).setUp()
     Consumer.get_collection().remove()
     model.Distributor.objects.delete()
     Bind.get_collection().remove()
     ConsumerHistoryEvent.get_collection().remove()
     plugin_api._create_manager()
     mock_plugins.install()
开发者ID:alanoe,项目名称:pulp,代码行数:10,代码来源:test_bind.py

示例4: tearDown

# 需要导入模块: from pulp.server.db.model.consumer import ConsumerHistoryEvent [as 别名]
# 或者: from pulp.server.db.model.consumer.ConsumerHistoryEvent import get_collection [as 别名]
 def tearDown(self):
     super(BindManagerTests, self).tearDown()
     Consumer.get_collection().remove()
     Repo.get_collection().remove()
     RepoDistributor.get_collection().remove()
     Bind.get_collection().remove()
     ConsumerHistoryEvent.get_collection().remove()
     mock_plugins.reset()
开发者ID:credativ,项目名称:pulp,代码行数:10,代码来源:test_bind.py

示例5: test_add_remove_duration

# 需要导入模块: from pulp.server.db.model.consumer import ConsumerHistoryEvent [as 别名]
# 或者: from pulp.server.db.model.consumer.ConsumerHistoryEvent import get_collection [as 别名]
 def test_add_remove_duration(self):
     collection = ConsumerHistoryEvent.get_collection()
     self.reaper.add_collection(collection, months=1)
     self.assertTrue(collection in self.reaper.collections)
     self.assertTrue(isinstance(self.reaper.collections[collection], Duration))
     self.reaper.remove_collection(collection)
     self.assertFalse(collection in self.reaper.collections)
开发者ID:ashcrow,项目名称:pulp,代码行数:9,代码来源:test_db_reaper.py

示例6: test_add_remove

# 需要导入模块: from pulp.server.db.model.consumer import ConsumerHistoryEvent [as 别名]
# 或者: from pulp.server.db.model.consumer.ConsumerHistoryEvent import get_collection [as 别名]
 def test_add_remove(self):
     collection = ConsumerHistoryEvent.get_collection()
     self.reaper.add_collection(collection, days=1)
     self.assertTrue(collection in self.reaper.collections)
     self.assertTrue(isinstance(self.reaper.collections[collection], timedelta))
     self.reaper.remove_collection(collection)
     self.assertFalse(collection in self.reaper.collections)
开发者ID:ashcrow,项目名称:pulp,代码行数:9,代码来源:test_db_reaper.py

示例7: test_bind_consumer_history

# 需要导入模块: from pulp.server.db.model.consumer import ConsumerHistoryEvent [as 别名]
# 或者: from pulp.server.db.model.consumer.ConsumerHistoryEvent import get_collection [as 别名]
 def test_bind_consumer_history(self, mock_repo_qs):
     self.populate()
     manager = factory.consumer_bind_manager()
     manager.bind(self.CONSUMER_ID, self.REPO_ID, self.DISTRIBUTOR_ID, self.NOTIFY_AGENT, self.BINDING_CONFIG)
     # Verify
     collection = ConsumerHistoryEvent.get_collection()
     history = collection.find_one(self.QUERY1)
     self.assertTrue(history is not None)
     self.assertEqual(history["consumer_id"], self.CONSUMER_ID)
     self.assertEqual(history["type"], "repo_bound")
     self.assertEqual(history["originator"], "SYSTEM")
     self.assertEqual(history["details"], self.DETAILS)
开发者ID:nbetm,项目名称:pulp,代码行数:14,代码来源:test_bind.py

示例8: test_remove_expired_entries

# 需要导入模块: from pulp.server.db.model.consumer import ConsumerHistoryEvent [as 别名]
# 或者: from pulp.server.db.model.consumer.ConsumerHistoryEvent import get_collection [as 别名]
    def test_remove_expired_entries(self, getfloat):
        chec = ConsumerHistoryEvent.get_collection()
        event = ConsumerHistoryEvent('consumer', 'originator', 'consumer_registered', {})
        chec.insert(event)
        self.assertTrue(chec.find({'_id': event['_id']}).count() == 1)
        # Let's mock getfloat to pretend that the user said they want to reap things from the
        # future, which should make the event we just created look old enough to delete
        getfloat.return_value = -1.0

        reaper.reap_expired_documents()

        # The event should no longer exist
        self.assertTrue(chec.find({'_id': event['_id']}).count() == 0)
开发者ID:alanoe,项目名称:pulp,代码行数:15,代码来源:test_reaper.py

示例9: test_leave_unexpired_entries

# 需要导入模块: from pulp.server.db.model.consumer import ConsumerHistoryEvent [as 别名]
# 或者: from pulp.server.db.model.consumer.ConsumerHistoryEvent import get_collection [as 别名]
    def test_leave_unexpired_entries(self, getfloat):
        chec = ConsumerHistoryEvent.get_collection()
        event = ConsumerHistoryEvent('consumer', 'originator', 'consumer_registered', {})
        chec.insert(event)
        self.assertTrue(chec.find({'_id': event['_id']}).count() == 1)
        # Let's mock getfloat to pretend that the user said they want to reap things that are a day
        # old. This means that the event should not get reaped.
        getfloat.return_value = 1.0

        reaper.reap_expired_documents()

        # The event should still exist
        self.assertTrue(chec.find({'_id': event['_id']}).count() == 1)
开发者ID:alanoe,项目名称:pulp,代码行数:15,代码来源:test_reaper.py

示例10: test_unbind_consumer_history

# 需要导入模块: from pulp.server.db.model.consumer import ConsumerHistoryEvent [as 别名]
# 或者: from pulp.server.db.model.consumer.ConsumerHistoryEvent import get_collection [as 别名]
 def test_unbind_consumer_history(self, mock_repo_qs):
     self.populate()
     manager = factory.consumer_bind_manager()
     manager.bind(self.CONSUMER_ID, self.REPO_ID, self.DISTRIBUTOR_ID,
                  self.NOTIFY_AGENT, self.BINDING_CONFIG)
     # Test
     manager.unbind(self.CONSUMER_ID, self.REPO_ID, self.DISTRIBUTOR_ID)
     # Verify
     collection = ConsumerHistoryEvent.get_collection()
     history = collection.find_one(self.QUERY2)
     self.assertTrue(history is not None)
     self.assertEqual(history['consumer_id'], self.CONSUMER_ID)
     self.assertEqual(history['type'], 'repo_unbound')
     self.assertEqual(history['originator'], 'SYSTEM')
     self.assertEqual(history['details'], self.DETAILS)
开发者ID:alanoe,项目名称:pulp,代码行数:17,代码来源:test_bind.py

示例11: test_update_with_consumer_history

# 需要导入模块: from pulp.server.db.model.consumer import ConsumerHistoryEvent [as 别名]
# 或者: from pulp.server.db.model.consumer.ConsumerHistoryEvent import get_collection [as 别名]
 def test_update_with_consumer_history(self):
     # Setup
     self.populate()
     manager = factory.consumer_profile_manager()
     manager.update(self.CONSUMER_ID, self.TYPE_1, self.PROFILE_1)
     # Test
     manager.update(self.CONSUMER_ID, self.TYPE_1, self.PROFILE_2)
     # Verify
     collection = ConsumerHistoryEvent.get_collection()
     history = collection.find_one({'consumer_id': self.CONSUMER_ID,
                                    'type': 'unit_profile_changed',
                                    'details': {'profile_content_type': self.TYPE_1}})
     self.assertTrue(history is not None)
     self.assertEqual(history['consumer_id'], self.CONSUMER_ID)
     self.assertEqual(history['type'], 'unit_profile_changed')
     self.assertEqual(history['originator'], 'SYSTEM')
     self.assertEqual(history['details'], {'profile_content_type': self.TYPE_1})
开发者ID:alanoe,项目名称:pulp,代码行数:19,代码来源:test_profile.py

示例12: test_remove_single_consumer_history

# 需要导入模块: from pulp.server.db.model.consumer import ConsumerHistoryEvent [as 别名]
# 或者: from pulp.server.db.model.consumer.ConsumerHistoryEvent import get_collection [as 别名]
    def test_remove_single_consumer_history(self):
        group_id = 'test_group'
        self.manager.create_consumer_group(group_id)
        group = self.collection.find_one({'id': group_id})

        consumer = self._create_consumer('test_consumer')
        self.assertFalse(consumer['id'] in group['consumer_ids'])
        criteria = Criteria(filters={'id': consumer['id']}, fields=['id'])
        self.manager.unassociate(group_id, criteria)

        collection = ConsumerHistoryEvent.get_collection()
        history = collection.find_one({'consumer_id': 'test_consumer', 'type': 'removed_from_group',
                                       'details': {'group_id': group_id}})
        self.assertTrue(history is not None)
        self.assertEqual(history['consumer_id'], 'test_consumer')
        self.assertEqual(history['type'], 'removed_from_group')
        self.assertEqual(history['originator'], 'SYSTEM')
        self.assertEqual(history['details'], {'group_id': group_id})
开发者ID:alanoe,项目名称:pulp,代码行数:20,代码来源:test_cud.py

示例13: clean

# 需要导入模块: from pulp.server.db.model.consumer import ConsumerHistoryEvent [as 别名]
# 或者: from pulp.server.db.model.consumer.ConsumerHistoryEvent import get_collection [as 别名]
    def clean(self):
        base.PulpServerTests.clean(self)

        Consumer.get_collection().remove()
        ConsumerHistoryEvent.get_collection().remove()
开发者ID:signull,项目名称:pulp,代码行数:7,代码来源:test_consumer_manager.py

示例14: clean

# 需要导入模块: from pulp.server.db.model.consumer import ConsumerHistoryEvent [as 别名]
# 或者: from pulp.server.db.model.consumer.ConsumerHistoryEvent import get_collection [as 别名]
 def clean(self):
     super(ScheduledUnitUninstallTests, self).clean()
     Consumer.get_collection().remove(safe=True)
     ConsumerHistoryEvent.get_collection().remove(safe=True)
开发者ID:ryanschneider,项目名称:pulp,代码行数:6,代码来源:test_schedule_cud_manager.py

示例15: setUp

# 需要导入模块: from pulp.server.db.model.consumer import ConsumerHistoryEvent [as 别名]
# 或者: from pulp.server.db.model.consumer.ConsumerHistoryEvent import get_collection [as 别名]
 def setUp(self):
     super(ReaperReapingTests, self).setUp()
     self.collection = ConsumerHistoryEvent.get_collection()
开发者ID:ashcrow,项目名称:pulp,代码行数:5,代码来源:test_db_reaper.py


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