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


Python RepoSyncResult.expected_result方法代码示例

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


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

示例1: test_sync_history_end_date

# 需要导入模块: from pulp.server.db.model.repository import RepoSyncResult [as 别名]
# 或者: from pulp.server.db.model.repository.RepoSyncResult import expected_result [as 别名]
    def test_sync_history_end_date(self):
        """
        Tests the functionality of requesting sync history before a given date
        """
        # Setup
        self.repo_manager.create_repo('test_repo')
        # A date string to fake some dates
        date_string = '2013-06-01T12:00:0%sZ'
        # Create 3 entries, with each date entry one second later
        for i in range(0, 6, 2):
            r = RepoSyncResult.expected_result('test_repo', 'foo', 'bar', date_string % str(i),
                                               date_string % str(i + 1), 1, 1, 1, '', '',
                                               RepoSyncResult.RESULT_SUCCESS)
            RepoSyncResult.get_collection().save(r, safe=True)

        # Verify three entries in test_repo
        self.assertEqual(3, len(self.sync_manager.sync_history('test_repo')))
        # Retrieve the first two entries
        end_date = '2013-06-01T12:00:03Z'
        end_entries = self.sync_manager.sync_history('test_repo', end_date=end_date)
        # Confirm the dates of the retrieved entries are earlier than or equal to the requested date
        self.assertEqual(2, len(end_entries))
        for entry in end_entries:
            retrieved = dateutils.parse_iso8601_datetime(entry['started'])
            given_end = dateutils.parse_iso8601_datetime(end_date)
            self.assertTrue(retrieved <= given_end)
开发者ID:beav,项目名称:pulp,代码行数:28,代码来源:test_sync.py

示例2: add_result

# 需要导入模块: from pulp.server.db.model.repository import RepoSyncResult [as 别名]
# 或者: from pulp.server.db.model.repository.RepoSyncResult import expected_result [as 别名]
def add_result(repo_id, offset):
    started = datetime.datetime.now(dateutils.local_tz())
    completed = started + datetime.timedelta(days=offset)
    r = RepoSyncResult.expected_result(repo_id, 'foo', 'bar', dateutils.format_iso8601_datetime(started),
                                       dateutils.format_iso8601_datetime(completed), 1, 1, 1, '', '',
                                       RepoSyncResult.RESULT_SUCCESS)
    RepoSyncResult.get_collection().save(r, safe=True)
开发者ID:cliffy94,项目名称:pulp,代码行数:9,代码来源:test_repo_sync_manager.py

示例3: test_sync_history_descending_sort

# 需要导入模块: from pulp.server.db.model.repository import RepoSyncResult [as 别名]
# 或者: from pulp.server.db.model.repository.RepoSyncResult import expected_result [as 别名]
    def test_sync_history_descending_sort(self):

        # Setup
        self.repo_manager.create_repo('test_sort')
        date_string = '2013-06-01T12:00:0%sZ'
        # Add some consecutive sync entries
        for i in range(0, 10, 2):
            r = RepoSyncResult.expected_result('test_sort', 'foo', 'bar', date_string % str(i),
                                               date_string % str(i + 1), 1, 1, 1, '', '',
                                               RepoSyncResult.RESULT_SUCCESS)
            RepoSyncResult.get_collection().save(r, safe=True)

        # Test sort by descending start date
        entries = self.sync_manager.sync_history(repo_id='test_sort', sort=constants.SORT_DESCENDING)
        self.assertEqual(5, len(entries))
        # Verify that each entry has a later completed date than the next one
        for i in range(0, 4):
            first = dateutils.parse_iso8601_datetime(entries[i]['started'])
            second = dateutils.parse_iso8601_datetime(entries[i + 1]['started'])
            self.assertTrue(first > second)
开发者ID:aweiteka,项目名称:pulp,代码行数:22,代码来源:test_sync.py

示例4: _

# 需要导入模块: from pulp.server.db.model.repository import RepoSyncResult [as 别名]
# 或者: from pulp.server.db.model.repository.RepoSyncResult import expected_result [as 别名]
                    result_code = RepoSyncResult.RESULT_SUCCESS

                else:
                    result_code = RepoSyncResult.RESULT_FAILED

            else:
                msg = _('Plugin type [%s] on repo [%s] did not return a valid sync report')
                msg = msg % (repo_importer['importer_type_id'], repo_id)
                logger.warn(msg)

                added_count = updated_count = removed_count = -1 # None?
                summary = details = msg
                result_code = RepoSyncResult.RESULT_ERROR # RESULT_UNKNOWN?

            result = RepoSyncResult.expected_result(
                repo_id, repo_importer['id'], repo_importer['importer_type_id'],
                sync_start_timestamp, sync_end_timestamp, added_count, updated_count, removed_count,
                summary, details, result_code)

        finally:
            # Do an update instead of a save in case the importer has changed the scratchpad
            importer_coll.update({'repo_id': repo_id}, {'$set': {'last_sync': sync_end_timestamp}},
                                 safe=True)
            # Add a sync history entry for this run
            sync_result_coll.save(result, safe=True)

        return result

    def sync_history(self, repo_id, limit=None, sort=constants.SORT_DESCENDING, start_date=None,
                     end_date=None):
        """
        Returns sync history entries for the given repo, sorted from most recent
开发者ID:aweiteka,项目名称:pulp,代码行数:34,代码来源:sync.py


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