~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_timestamp.py

  • Committer: Rory Yorke
  • Date: 2010-10-20 14:38:53 UTC
  • mto: This revision was merged to the branch mainline in revision 5519.
  • Revision ID: rory.yorke@gmail.com-20101020143853-9kfd2ldcjfroh8jw
Show missing files in bzr status (bug 134168).

"bzr status" will now show missing files, that is, those added with "bzr
add" and then removed by non bzr means (e.g., rm).

Blackbox tests were added for this case, and tests were also added to
test_delta, since the implementation change is in bzrlib.delta.

Might also affect bug 189709.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2009, 2011 Canonical Ltd
 
1
# Copyright (C) 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
import random
18
 
import time
19
 
 
20
 
 
21
17
from bzrlib import (
22
18
    tests,
23
19
    timestamp,
24
20
    )
25
 
from bzrlib.osutils import local_time_offset
26
 
 
27
21
 
28
22
class TestPatchHeader(tests.TestCase):
29
23
 
58
52
        # offset of three minutes
59
53
        self.assertEqual((1173193459, +3 * 60),
60
54
            timestamp.parse_patch_date('2007-03-06 15:07:19 +0003'))
61
 
 
62
 
 
63
 
class UnpackHighresDateTests(tests.TestCase):
64
 
 
65
 
    def test_unpack_highres_date(self):
66
 
        self.assertEquals(
67
 
            (1120153132.3508501, -18000),
68
 
            timestamp.unpack_highres_date('Thu 2005-06-30 12:38:52.350850105 -0500'))
69
 
        self.assertEquals(
70
 
            (1120153132.3508501, 0),
71
 
            timestamp.unpack_highres_date('Thu 2005-06-30 17:38:52.350850105 +0000'))
72
 
        self.assertEquals(
73
 
            (1120153132.3508501, 7200),
74
 
            timestamp.unpack_highres_date('Thu 2005-06-30 19:38:52.350850105 +0200'))
75
 
        self.assertEquals(
76
 
            (1152428738.867522, 19800),
77
 
            timestamp.unpack_highres_date('Sun 2006-07-09 12:35:38.867522001 +0530'))
78
 
 
79
 
    def test_random(self):
80
 
        t = time.time()
81
 
        o = local_time_offset()
82
 
        t2, o2 = timestamp.unpack_highres_date(timestamp.format_highres_date(t, o))
83
 
        self.assertEquals(t, t2)
84
 
        self.assertEquals(o, o2)
85
 
        t -= 24*3600*365*2 # Start 2 years ago
86
 
        o = -12*3600
87
 
        for count in xrange(500):
88
 
            t += random.random()*24*3600*30
89
 
            o = ((o/3600 + 13) % 25 - 12)*3600 # Add 1 wrap around from [-12, 12]
90
 
            date = timestamp.format_highres_date(t, o)
91
 
            t2, o2 = timestamp.unpack_highres_date(date)
92
 
            self.assertEquals(t, t2,
93
 
                'Failed on date %r, %s,%s diff:%s' % (date, t, o, t2-t))
94
 
            self.assertEquals(o, o2,
95
 
                'Failed on date %r, %s,%s diff:%s' % (date, t, o, t2-t))