コード例 #1
0
def assert_last_sync_time(time_in_iso):
    now = datetime.datetime.now(dateutils.local_tz())
    finished = dateutils.parse_iso8601_datetime(time_in_iso)

    # Compare them within a threshold since they won't be exact
    difference = now - finished
    return difference.seconds < 2
コード例 #2
0
ファイル: test_repo_sync_manager.py プロジェクト: sahwar/pulp
def assert_last_sync_time(time_in_iso):
    now = datetime.datetime.now(dateutils.local_tz())
    finished = dateutils.parse_iso8601_datetime(time_in_iso)

    # Compare them within a threshold since they won't be exact
    difference = now - finished
    return difference.seconds < 2
コード例 #3
0
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)
コード例 #4
0
 def test_ensure_tz_specified(self):
     """
     If the timezone is specified, the result should be the same.
     """
     dt = datetime.datetime.now(dateutils.local_tz())
     new_date = Repository._ensure_tz_specified(dt)
     self.assertEquals(new_date.tzinfo, dateutils.utc_tz())
コード例 #5
0
 def test_tz_specified(self):
     """
     Ensure that if the tz is already specified, it is used.
     """
     dt = datetime.datetime.now(dateutils.local_tz())
     new_date = dateutils.ensure_tz(dt)
     self.assertEquals(new_date.tzinfo, dateutils.utc_tz())
コード例 #6
0
ファイル: test_dateutils.py プロジェクト: aweiteka/pulp
 def test_datetime_with_tz(self):
     n = datetime.datetime.now(dateutils.local_tz())
     s = dateutils.format_iso8601_datetime(n)
     b = dateutils.parse_iso8601_datetime(s)
     for f in self.dt_fields:
         self.assertTrue(
             getattr(n, f) == getattr(b, f), 'Field mismatch: %s' % f)
コード例 #7
0
ファイル: test_model.py プロジェクト: nbetm/pulp
 def test_ensure_tz_specified(self):
     """
     If the timezone is specified, the result should be the same.
     """
     dt = datetime.datetime.now(dateutils.local_tz())
     new_date = Repository._ensure_tz_specified(dt)
     self.assertEquals(new_date.tzinfo, dateutils.utc_tz())
コード例 #8
0
def add_result(repo_id, dist_id, offset):
    started = datetime.datetime.now(dateutils.local_tz())
    completed = started + datetime.timedelta(days=offset)
    r = RepoPublishResult.expected_result(
        repo_id, dist_id, 'bar', dateutils.format_iso8601_datetime(started),
        dateutils.format_iso8601_datetime(completed), 'test-summary',
        'test-details', RepoPublishResult.RESULT_SUCCESS)
    RepoPublishResult.get_collection().insert(r, safe=True)
コード例 #9
0
ファイル: publish.py プロジェクト: fdammeke/pulp
def _now_timestamp():
    """
    @return: timestamp suitable for indicating when a publish completed
    @rtype:  str
    """
    now = datetime.datetime.now(dateutils.local_tz())
    now_in_iso_format = dateutils.format_iso8601_datetime(now)
    return now_in_iso_format
コード例 #10
0
ファイル: test_repo_sync_manager.py プロジェクト: sahwar/pulp
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)
コード例 #11
0
def _now_timestamp():
    """
    @return: timestamp suitable for indicating when a publish completed
    @rtype:  str
    """
    now = datetime.datetime.now(dateutils.local_tz())
    now_in_iso_format = dateutils.format_iso8601_datetime(now)
    return now_in_iso_format
コード例 #12
0
    def test_last_publish(self):
        # Setup
        self.publish_manager.publish(self.group_id, self.distributor_id)

        # Test
        last_publish = self.publish_manager.last_publish(self.group_id, self.distributor_id)

        # Verify
        now = datetime.datetime.now(dateutils.local_tz())
        difference = now - last_publish
        self.assertTrue(difference.seconds < 2)
コード例 #13
0
ファイル: history.py プロジェクト: ktdreyer/pulp
    def cull_history(self, lifetime):
        '''
        Deletes all consumer history entries that are older than the given lifetime.

        @param lifetime: length in days; history entries older than this many days old
                         are deleted in this call
        @type  lifetime: L{datetime.timedelta}
        '''
        now = datetime.datetime.now(dateutils.local_tz())
        limit = dateutils.format_iso8601_datetime(now - lifetime)
        spec = {'timestamp': {'$lt': limit}}
        self.collection.remove(spec, safe=False)
コード例 #14
0
    def test_last_publish(self):
        # Setup
        distributor, instance, config = self.publish_manager._get_distributor_instance_and_config(self.group_id, self.distributor_id)
        self.publish_manager.publish(self.group_id, self.distributor_id, distributor, instance, config)

        # Test
        last_publish = self.publish_manager.last_publish(self.group_id, self.distributor_id)

        # Verify
        now = datetime.datetime.now(dateutils.local_tz())
        difference = now - last_publish
        self.assertTrue(difference.seconds < 2)
コード例 #15
0
ファイル: history.py プロジェクト: jeremycline/pulp
    def cull_history(self, lifetime):
        '''
        Deletes all consumer history entries that are older than the given lifetime.

        @param lifetime: length in days; history entries older than this many days old
                         are deleted in this call
        @type  lifetime: L{datetime.timedelta}
        '''
        now = datetime.datetime.now(dateutils.local_tz())
        limit = dateutils.format_iso8601_datetime(now - lifetime)
        spec = {'timestamp': {'$lt': limit}}
        self.collection.remove(spec, safe=False)
コード例 #16
0
    def test_last_publish(self):
        # Setup
        self.publish_manager.publish(self.group_id, self.distributor_id)

        # Test
        last_publish = self.publish_manager.last_publish(
            self.group_id, self.distributor_id)

        # Verify
        now = datetime.datetime.now(dateutils.local_tz())
        difference = now - last_publish
        self.assertTrue(difference.seconds < 2)
コード例 #17
0
def add_result(repo_id, dist_id, offset):
    started = datetime.datetime.now(dateutils.local_tz())
    completed = started + datetime.timedelta(days=offset)
    r = RepoPublishResult.expected_result(
        repo_id,
        dist_id,
        "bar",
        dateutils.format_iso8601_datetime(started),
        dateutils.format_iso8601_datetime(completed),
        "test-summary",
        "test-details",
        RepoPublishResult.RESULT_SUCCESS,
    )
    RepoPublishResult.get_collection().insert(r, safe=True)
コード例 #18
0
ファイル: pickling.py プロジェクト: tomlanyon/pulp
def unpickle_timezone_information(offset):
    """
    Unpickle timezone information
    @param offset: timezone utc offset
    """
    utc_tz = dateutils.utc_tz()
    utc_offset = utc_tz.utcoffset(None)
    if offset == utc_offset:
        return utc_tz
    local_tz = dateutils.local_tz()
    local_offset = local_tz.utcoffset(None)
    if offset == local_offset:
        return local_tz
    offset_hours = offset.days * 24
    offset_minutes = offset.seconds / 60
    return isodate.FixedOffset(offset_hours, offset_minutes)
コード例 #19
0
ファイル: pickling.py プロジェクト: ashcrow/pulp
def unpickle_timezone_information(offset):
    """
    Unpickle timezone information
    @param offset: timezone utc offset
    """
    utc_tz = dateutils.utc_tz()
    utc_offset = utc_tz.utcoffset(None)
    if offset == utc_offset:
        return utc_tz
    local_tz = dateutils.local_tz()
    local_offset = local_tz.utcoffset(None)
    if offset == local_offset:
        return local_tz
    offset_hours = offset.days * 24
    offset_minutes = offset.seconds / 60
    return isodate.FixedOffset(offset_hours, offset_minutes)
コード例 #20
0
ファイル: test_dateutils.py プロジェクト: ehelms/pulp
 def test_datetime_with_tz(self):
     n = datetime.datetime.now(dateutils.local_tz())
     s = dateutils.format_iso8601_datetime(n)
     b = dateutils.parse_iso8601_datetime(s)
     for f in self.dt_fields:
         self.assertTrue(getattr(n, f) == getattr(b, f), 'Field mismatch: %s' % f)
コード例 #21
0
ファイル: test_dateutils.py プロジェクト: ehelms/pulp
 def test_utc_offset(self):
     n1 = datetime.datetime.now(dateutils.local_tz())
     u1 = dateutils.to_utc_datetime(n1)
     n2 = n1.replace(tzinfo=None)
     u2 = u1.replace(tzinfo=None)
     self.assertTrue(n2 - u2 == dateutils.local_utcoffset_delta())
コード例 #22
0
ファイル: test_dateutils.py プロジェクト: ehelms/pulp
 def test_local_to_utz_tz_conversion(self):
     n1 = datetime.datetime.now(dateutils.local_tz())
     u = dateutils.to_utc_datetime(n1)
     n2 = dateutils.to_local_datetime(u)
     self.assertTrue(n1 == n2)
コード例 #23
0
 def test_utc_offset(self):
     n1 = datetime.datetime.now(dateutils.local_tz())
     u1 = dateutils.to_utc_datetime(n1)
     n2 = n1.replace(tzinfo=None)
     u2 = u1.replace(tzinfo=None)
     self.assertTrue(n2 - u2 == dateutils.local_utcoffset_delta())
コード例 #24
0
 def test_local_to_utz_tz_conversion(self):
     n1 = datetime.datetime.now(dateutils.local_tz())
     u = dateutils.to_utc_datetime(n1)
     n2 = dateutils.to_local_datetime(u)
     self.assertTrue(n1 == n2)
コード例 #25
0
ファイル: test_common.py プロジェクト: pombreda/pulp
 def test_tz_specified(self):
     dt = datetime.datetime.now(dateutils.local_tz())
     new_date = _ensure_tz_specified(dt)
     self.assertEquals(new_date.tzinfo, dateutils.utc_tz())