comparison tests/test_parse.py @ 0:26e919a36f86 default tip

speedtest containerized dispatching software
author Jeff Hammel <k0scist@gmail.com>
date Thu, 09 Feb 2017 09:47:04 -0800
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:26e919a36f86
1 #!/usr/bin/env python
2
3 """
4 test parsing
5 """
6
7 # imports
8 import speedtest.parse
9 import os
10 import shutil
11 import tempfile
12 import unittest
13
14 here = os.path.dirname(os.path.abspath(__file__))
15
16 class ParsingTest(unittest.TestCase):
17
18 def test_parse_columns(self):
19 """test columns parsing"""
20
21 columns = ['REPOSITORY',
22 'TAG',
23 'IMAGE ID',
24 'CREATED',
25 'VIRTUAL SIZE']
26
27 # load data
28 output = open(os.path.join(here, 'data', 'docker_images.out')).read()
29
30 # parse the data
31 data = speedtest.parse.parse_columns(output, columns)
32 # (Pdb) data[-1]
33 # {'REPOSITORY': 'steeef/sensu-centos', 'CREATED': '2 years ago', 'IMAGE': 'b6f14e', 'VIRTUAL': '1.284 GB', 'TAG': 'latest', 'ID': 'cbffa0', 'SIZE': ''}
34 self.assertEqual(data[-1].get("IMAGE ID"), "b6f14ecbffa0")
35
36 if __name__ == '__main__':
37 unittest.main()