aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/common/test_utils.py
diff options
context:
space:
mode:
authorKubi <jean.gaoliang@huawei.com>2017-07-06 12:14:34 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-07-06 12:14:34 +0000
commit2bea82e39d62246552a9d6d49c74bbc32747f018 (patch)
tree4a83bfb2b001f7ef4ab51933c91e51df4a848755 /tests/unit/common/test_utils.py
parent917dea49415183eaff6d2f2fbf32ddeff64d9dfe (diff)
parent25a37b2048281c64719bd6ad67860f65f6c31546 (diff)
Merge "move flatten dict key to common utils"
Diffstat (limited to 'tests/unit/common/test_utils.py')
-rw-r--r--tests/unit/common/test_utils.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/unit/common/test_utils.py b/tests/unit/common/test_utils.py
index 8f52b53b0..c4c61ceeb 100644
--- a/tests/unit/common/test_utils.py
+++ b/tests/unit/common/test_utils.py
@@ -109,6 +109,37 @@ class GetParaFromYaml(unittest.TestCase):
return file_path
+class CommonUtilTestCase(unittest.TestCase):
+ def setUp(self):
+ self.data = {
+ "benchmark": {
+ "data": {
+ "mpstat": {
+ "cpu0": {
+ "%sys": "0.00",
+ "%idle": "99.00"
+ },
+ "loadavg": [
+ "1.09",
+ "0.29"
+ ]
+ },
+ "rtt": "1.03"
+ }
+ }
+ }
+ def test__dict_key_flatten(self):
+ line = 'mpstat.loadavg1=0.29,rtt=1.03,mpstat.loadavg0=1.09,' \
+ 'mpstat.cpu0.%idle=99.00,mpstat.cpu0.%sys=0.00'
+ # need to sort for assert to work
+ line = ",".join(sorted(line.split(',')))
+ flattened_data = utils.flatten_dict_key(
+ self.data['benchmark']['data'])
+ result = ",".join(
+ ("=".join(item) for item in sorted(flattened_data.items())))
+ self.assertEqual(result, line)
+
+
def main():
unittest.main()