Fixed metadata usage being served as strings

Metadata usage should be served as ints, as it is numeric.
This commit is contained in:
Marta Marczykowska-Górecka 2019-11-19 00:33:30 +01:00
parent 9ba2ad2e29
commit 05edea703d
No known key found for this signature in database
GPG Key ID: 9A752C30B26FD04B
2 changed files with 10 additions and 5 deletions

View File

@ -278,7 +278,12 @@ class Pool(object):
pool_usage_data = pool_usage_data.decode('utf-8')
assert pool_usage_data.endswith('\n')
pool_usage_data = pool_usage_data[:-1]
return dict(l.split('=', 1) for l in pool_usage_data.splitlines())
def _int_split(text): # pylint: disable=missing-docstring
key, value = text.split("=", 1)
return key, int(value)
return dict(_int_split(l) for l in pool_usage_data.splitlines())
@property
def config(self):

View File

@ -313,10 +313,10 @@ class TestPool(qubesadmin.tests.QubesTestCase):
b'metadata_usage=50\n'
pool = self.app.pools['lvm']
self.assertEqual(pool.usage_details, {
'data_size': '204800',
'data_usage': '102400',
'metadata_size': '1024',
'metadata_usage': '50',
'data_size': 204800,
'data_usage': 102400,
'metadata_size': 1024,
'metadata_usage': 50,
})
self.assertAllCalled()