Esempio n. 1
0
 def test_abbreviate_rate(self):
     self.failUnlessReallyEqual(common.abbreviate_rate(None), "")
     self.failUnlessReallyEqual(common.abbreviate_rate(1234000), "1.23MBps")
     self.failUnlessReallyEqual(common.abbreviate_rate(12340), "12.3kBps")
     self.failUnlessReallyEqual(common.abbreviate_rate(123), "123Bps")
     self.failUnlessReallyEqual(common.abbreviate_rate(2500000), "2.50MBps")
     self.failUnlessReallyEqual(common.abbreviate_rate(30100), "30.1kBps")
     self.failUnlessReallyEqual(common.abbreviate_rate(123), "123Bps")
Esempio n. 2
0
    def test_abbreviate_time(self):
        self.failUnlessReallyEqual(common.abbreviate_time(None), "")
        self.failUnlessReallyEqual(common.abbreviate_time(1.234), "1.23s")
        self.failUnlessReallyEqual(common.abbreviate_time(0.123), "123ms")
        self.failUnlessReallyEqual(common.abbreviate_time(0.00123), "1.2ms")
        self.failUnlessReallyEqual(common.abbreviate_time(0.000123), "123us")
        self.failUnlessReallyEqual(common.abbreviate_time(-123000), "-123000000000us")
        self.failUnlessReallyEqual(common.abbreviate_time(2.5), "2.50s")
        self.failUnlessReallyEqual(common.abbreviate_time(0.25), "250ms")
        self.failUnlessReallyEqual(common.abbreviate_time(0.0021), "2.1ms")

        self.failUnlessReallyEqual(common.abbreviate_time(None), "")
        self.failUnlessReallyEqual(common.abbreviate_time(2.5), "2.50s")
        self.failUnlessReallyEqual(common.abbreviate_time(0.25), "250ms")
        self.failUnlessReallyEqual(common.abbreviate_time(0.0021), "2.1ms")
        self.failUnlessReallyEqual(common.abbreviate_time(0.000123), "123us")
        self.failUnlessReallyEqual(common.abbreviate_rate(None), "")
        self.failUnlessReallyEqual(common.abbreviate_rate(2500000), "2.50MBps")
        self.failUnlessReallyEqual(common.abbreviate_rate(30100), "30.1kBps")
        self.failUnlessReallyEqual(common.abbreviate_rate(123), "123Bps")
Esempio n. 3
0
    def test_compute_rate(self):
        self.failUnlessReallyEqual(common.compute_rate(None, None), None)
        self.failUnlessReallyEqual(common.compute_rate(None, 1), None)
        self.failUnlessReallyEqual(common.compute_rate(250000, None), None)
        self.failUnlessReallyEqual(common.compute_rate(250000, 0), None)
        self.failUnlessReallyEqual(common.compute_rate(250000, 10), 25000.0)
        self.failUnlessReallyEqual(common.compute_rate(0, 10), 0.0)
        self.shouldFail(AssertionError, "test_compute_rate", "",
                        common.compute_rate, -100, 10)
        self.shouldFail(AssertionError, "test_compute_rate", "",
                        common.compute_rate, 100, -10)

        # Sanity check
        rate = common.compute_rate(10*1000*1000, 1)
        self.failUnlessReallyEqual(common.abbreviate_rate(rate), "10.00MBps")
Esempio n. 4
0
 def render_rate(self, ctx, data):
     return abbreviate_rate(data)
Esempio n. 5
0
 def render_rate(self, ctx, data):
     return abbreviate_rate(data)
Esempio n. 6
0
 def test_abbreviate_rate(self):
     self.failUnlessReallyEqual(common.abbreviate_rate(None), "")
     self.failUnlessReallyEqual(common.abbreviate_rate(1234000), "1.23MBps")
     self.failUnlessReallyEqual(common.abbreviate_rate(12340), "12.3kBps")
     self.failUnlessReallyEqual(common.abbreviate_rate(123), "123Bps")