Mercurial > hg > speedtest
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test_parse.py Thu Feb 09 09:47:04 2017 -0800 @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +""" +test parsing +""" + +# imports +import speedtest.parse +import os +import shutil +import tempfile +import unittest + +here = os.path.dirname(os.path.abspath(__file__)) + +class ParsingTest(unittest.TestCase): + + def test_parse_columns(self): + """test columns parsing""" + + columns = ['REPOSITORY', + 'TAG', + 'IMAGE ID', + 'CREATED', + 'VIRTUAL SIZE'] + + # load data + output = open(os.path.join(here, 'data', 'docker_images.out')).read() + + # parse the data + data = speedtest.parse.parse_columns(output, columns) + # (Pdb) data[-1] + # {'REPOSITORY': 'steeef/sensu-centos', 'CREATED': '2 years ago', 'IMAGE': 'b6f14e', 'VIRTUAL': '1.284 GB', 'TAG': 'latest', 'ID': 'cbffa0', 'SIZE': ''} + self.assertEqual(data[-1].get("IMAGE ID"), "b6f14ecbffa0") + +if __name__ == '__main__': + unittest.main()