• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python consumer.ConsumerHistoryEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: record_event

    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,代码行数:31,代码来源:history.py


示例2: tearDown

 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,代码行数:8,代码来源:test_bind.py


示例3: setUp

 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,代码行数:8,代码来源:test_bind.py


示例4: tearDown

 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,代码行数:8,代码来源:test_bind.py


示例5: test_add_remove_duration

 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,代码行数:7,代码来源:test_db_reaper.py


示例6: test_add_remove

 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,代码行数:7,代码来源:test_db_reaper.py


示例7: test_bind_consumer_history

 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,代码行数:12,代码来源:test_bind.py


示例8: test_remove_expired_entries

    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,代码行数:13,代码来源:test_reaper.py


示例9: test_leave_unexpired_entries

    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,代码行数:13,代码来源:test_reaper.py


示例10: test_unbind_consumer_history

 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,代码行数:15,代码来源:test_bind.py


示例11: test_update_with_consumer_history

 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,代码行数:17,代码来源:test_profile.py


示例12: test_remove_single_consumer_history

    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,代码行数:18,代码来源:test_cud.py


示例13: clean

    def clean(self):
        base.PulpServerTests.clean(self)

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


示例14: clean

 def clean(self):
     super(ScheduledUnitUninstallTests, self).clean()
     Consumer.get_collection().remove(safe=True)
     ConsumerHistoryEvent.get_collection().remove(safe=True)
开发者ID:ryanschneider,项目名称:pulp,代码行数:4,代码来源:test_schedule_cud_manager.py


示例15: setUp

 def setUp(self):
     super(ReaperReapingTests, self).setUp()
     self.collection = ConsumerHistoryEvent.get_collection()
开发者ID:ashcrow,项目名称:pulp,代码行数:3,代码来源:test_db_reaper.py


示例16: tearDown

 def tearDown(self):
     """
     Clean up the records we made.
     """
     super(TestReapExpiredDocuments, self).tearDown()
     ConsumerHistoryEvent.get_collection().remove()
开发者ID:alanoe,项目名称:pulp,代码行数:6,代码来源:test_reaper.py


示例17: query

    def query(self, consumer_id=None, event_type=None, limit=None, sort='descending',
              start_date=None, end_date=None):
        '''
        Queries the consumer history storage.

        @param consumer_id: if specified, events will only be returned for the the
                            consumer referenced
        @type  consumer_id: string or number

        @param event_type: if specified, only events of the given type are returned
        @type  event_type: string (enumeration found in TYPES)

        @param limit: if specified, the query will only return up to this amount of
                      entries; default is to not limit the entries returned
        @type  limit: number greater than zero

        @param sort: indicates the sort direction of the results; results are sorted
                     by timestamp
        @type  sort: string; valid values are 'ascending' and 'descending'

        @param start_date: if specified, no events prior to this date will be returned
        @type  start_date: datetime.datetime

        @param end_date: if specified, no events after this date will be returned
        @type  end_date: datetime.datetime

        @return: list of consumer history entries that match the given parameters;
                 empty list (not None) if no matching entries are found
        @rtype:  list of ConsumerHistoryEvent instances

        @raises MissingResource: if the given consumer does not exist
        @raises InvalidValue: if any of the fields is unacceptable
        '''
        invalid_values = []
        if event_type is not None and event_type not in TYPES:
            invalid_values.append('event_type')

        # Verify the limit makes sense
        if limit is not None and limit < 1:
            invalid_values.append('limit')

        # Verify the sort direction is valid
        if sort not in SORT_DIRECTION:
            invalid_values.append('sort')

        # Verify that start_date and end_date is valid
        if start_date is not None:
            try:
                dateutils.parse_iso8601_date(start_date)
            except (ValueError, isodate.ISO8601Error):
                invalid_values.append('start_date')
        if end_date is not None:
            try:
                dateutils.parse_iso8601_date(end_date)
            except (ValueError, isodate.ISO8601Error):
                invalid_values.append('end_date')

        if invalid_values:
            raise InvalidValue(invalid_values)

        # Assemble the mongo search parameters
        search_params = {}
        if consumer_id:
            search_params['consumer_id'] = consumer_id
        if event_type:
            search_params['type'] = event_type

        # Add in date range limits if specified
        date_range = {}
        if start_date:
            date_range['$gte'] = start_date
        if end_date:
            date_range['$lte'] = end_date

        if len(date_range) > 0:
            search_params['timestamp'] = date_range

        # Determine the correct mongo cursor to retrieve
        if len(search_params) == 0:
            cursor = ConsumerHistoryEvent.get_collection().find()
        else:
            cursor = ConsumerHistoryEvent.get_collection().find(search_params)

        # Sort by most recent entry first
        cursor.sort('timestamp', direction=SORT_DIRECTION[sort])

        # If a limit was specified, add it to the cursor
        if limit:
            cursor.limit(limit)

        # Finally convert to a list before returning
        return list(cursor)
开发者ID:jeremycline,项目名称:pulp,代码行数:92,代码来源:history.py


示例18: _validate_consumer_history

def _validate_consumer_history():
    objectdb = ConsumerHistoryEvent.get_collection()
    reference = ConsumerHistoryEvent('', '', '', {})
    return _validate_model(ConsumerHistoryEvent.__name__, objectdb, reference)
开发者ID:ehelms,项目名称:pulp,代码行数:4,代码来源:validate.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python consumer.RepoProfileApplicability类代码示例发布时间:2022-05-25
下一篇:
Python consumer.ConsumerGroup类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap