diff options
author | ben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2002-05-24 17:48:57 +0000 |
---|---|---|
committer | ben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2002-05-24 17:48:57 +0000 |
commit | 9b6416eaf5e1691d2e640a5da2a14b4efac38348 (patch) | |
tree | 97b729eac13f4534f8712a056ece478c126600a0 | |
parent | 2b607c5539d60002ee56c0275ead5c798d5a403b (diff) | |
download | rdiff-backup-9b6416eaf5e1691d2e640a5da2a14b4efac38348.tar.gz |
Added tests for prettier statistics printing, stats averaging
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@107 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
-rw-r--r-- | rdiff-backup/testing/statisticstest.py | 31 | ||||
-rw-r--r-- | rdiff-backup/testing/timetest.py | 8 |
2 files changed, 37 insertions, 2 deletions
diff --git a/rdiff-backup/testing/statisticstest.py b/rdiff-backup/testing/statisticstest.py index 1fd8847..d32326f 100644 --- a/rdiff-backup/testing/statisticstest.py +++ b/rdiff-backup/testing/statisticstest.py @@ -38,8 +38,9 @@ class StatsObjTest(unittest.TestCase): self.set_obj(s) stats_string = s.get_stats_string() assert stats_string == \ -"""StartTime 11 -EndTime 12 +"""StartTime 11 (Wed Dec 31 16:00:11 1969) +EndTime 12 (Wed Dec 31 16:00:12 1969) +ElapsedTime 1 (1 second) SourceFiles 1 SourceFileSize 2 NewFiles 3 @@ -80,5 +81,31 @@ IncrementFileSize 10""", "'%s'" % stats_string s2.read_stats_from_rp(rp) assert s2.stats_equal(s) + def testAverage(self): + """Test making an average statsobj""" + s1 = StatsObj() + s1.StartTime = 5 + s1.EndTime = 10 + s1.ElapsedTime = 5 + s1.ChangedFiles = 2 + s1.SourceFiles = 100 + s1.NewFileSize = 4 + + s2 = StatsObj() + s2.StartTime = 25 + s2.EndTime = 35 + s2.ElapsedTime = 10 + s2.ChangedFiles = 1 + s2.SourceFiles = 50 + s2.DeletedFiles = 0 + + s3 = StatsObj().set_to_average([s1, s2]) + assert s3.StartTime is s3.EndTime is None + assert s3.ElapsedTime == 7.5 + assert s3.DeletedFiles is s3.NewFileSize is None, (s3.DeletedFiles, + s3.NewFileSize) + assert s3.ChangedFiles == 1.5 + assert s3.SourceFiles == 75 + if __name__ == "__main__": unittest.main() diff --git a/rdiff-backup/testing/timetest.py b/rdiff-backup/testing/timetest.py index d56f420..7d8fd3a 100644 --- a/rdiff-backup/testing/timetest.py +++ b/rdiff-backup/testing/timetest.py @@ -77,6 +77,14 @@ class TimeTest(unittest.TestCase): assert i2s("1M2W4D2h5m20s") == (30*86400 + 2*7*86400 + 4*86400 + 2*3600 + 5*60 + 20) + def testPrettyIntervals(self): + """Test printable interval conversion""" + assert Time.inttopretty(3600) == "1 hour" + assert Time.inttopretty(7220) == "2 hours 20 seconds" + assert Time.inttopretty(0) == "0 seconds" + assert Time.inttopretty(353) == "5 minutes 53 seconds" + assert Time.inttopretty(3661) == "1 hour 1 minute 1 second" + def testGenericString(self): """Test genstrtotime, conversion of arbitrary string to time""" g2t = Time.genstrtotime |