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