summaryrefslogtreecommitdiff
path: root/rdiff-backup/testing
diff options
context:
space:
mode:
authorben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-05-01 05:30:35 +0000
committerben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-05-01 05:30:35 +0000
commitd33428ca8e5e59f6f3258a637d147d3622c1d33f (patch)
tree04b6b65d4e3b746866e4a48a7516571f9516b918 /rdiff-backup/testing
parent874f6676cc7694e944c2d38235480605ee3c0815 (diff)
downloadrdiff-backup-d33428ca8e5e59f6f3258a637d147d3622c1d33f.tar.gz
Added code to test the new time formats allowed
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@52 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/testing')
-rw-r--r--rdiff-backup/testing/timetest.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/rdiff-backup/testing/timetest.py b/rdiff-backup/testing/timetest.py
index f7a6fcd..78c7f97 100644
--- a/rdiff-backup/testing/timetest.py
+++ b/rdiff-backup/testing/timetest.py
@@ -67,5 +67,28 @@ class TimeTest(unittest.TestCase):
assert i2s("400m") == 400*60
assert i2s("1Y") == 365*86400
assert i2s("30h") == 30*60*60
+ assert i2s("3W") == 3*7*86400
+
+ def testIntervalsComposite(self):
+ """Like above, but allow composite intervals"""
+ i2s = Time.intstringtoseconds
+ assert i2s("7D2h") == 7*86400 + 2*3600
+ assert i2s("2Y3s") == 2*365*86400 + 3
+ assert i2s("1M2W4D2h5m20s") == (30*86400 + 2*7*86400 + 4*86400 +
+ 2*3600 + 5*60 + 20)
+
+ def testGenericString(self):
+ """Test genstrtotime, conversion of arbitrary string to time"""
+ g2t = Time.genstrtotime
+ assert g2t('now', 1000) == 1000
+ assert g2t('2h3s', 10000) == 10000 - 2*3600 - 3
+ assert g2t('2001-09-01T21:49:04Z') == \
+ Time.stringtotime('2001-09-01T21:49:04Z')
+ assert g2t('2002-04-26T04:22:01') == \
+ Time.stringtotime('2002-04-26T04:22:01' + Time.gettzd())
+ t = Time.stringtotime('2001-05-12T00:00:00' + Time.gettzd())
+ assert g2t('2001-05-12') == t
+ assert g2t('2001/05/12') == t
+ assert g2t('5/12/2001') == t
if __name__ == '__main__': unittest.main()