當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。