[modules/traffic] compute theme.minwidth based on traffic.format

This commit is contained in:
me 2020-01-18 19:02:04 +02:00
parent 36c9a24ac4
commit 2f6a2285bd
2 changed files with 39 additions and 1 deletions

View file

@ -0,0 +1,23 @@
import mock
import unittest
import tests.mocks as mocks
from bumblebee.modules.traffic import Module
class TestTrafficModule(unittest.TestCase):
def setUp(self):
mocks.setup_test(self, Module)
def test_default_format(self):
self.assertEqual(self.module._format, "{:.2f}")
def test_get_minwidth_str(self):
# default value (two digits after dot)
self.assertEqual(self.module.get_minwidth_str(), "1000.00MB")
# integer value
self.module._format = "{:.0f}"
self.assertEqual(self.module.get_minwidth_str(), "1000MB")
# just one digit after dot
self.module._format = "{:.1f}"
self.assertEqual(self.module.get_minwidth_str(), "1000.0MB")