Refactor Model class
[netvirt.git] / resources / tools / odltools / odltools / mdsal / tests / test_cmd.py
1 import logging
2 import os
3 import shutil
4 import unittest
5
6 from odltools import logg
7 from odltools.mdsal import cmd
8 from odltools.mdsal.tests import Args
9
10
11 @unittest.skip("skipping")
12 class TestCmd(unittest.TestCase):
13     def setUp(self):
14         logg.Logger(logging.INFO, logging.INFO)
15         self.args = Args(path="/tmp/testmodels", pretty_print=True)
16
17     def test_get_all_dumps(self):
18         # Ensure odl is running at localhost:8181
19         # Remove an existing directory
20         if os.path.exists(self.args.path):
21             if os.path.islink(self.args.path):
22                 os.unlink(self.args.path)
23             else:
24                 shutil.rmtree(self.args.path)
25
26         cmd.get_all_dumps(self.args)
27
28         # assert each model has been saved to a file
29         for res in cmd.DSMAP.itervalues():
30             store = res[cmd.DSM_DSTYPE]
31             model_path = res[cmd.DSM_PATH]
32             path_split = cmd.split_model_path(model_path)
33             filename = cmd.make_filename(self.args.path, store, path_split.name, path_split.container)
34             self.assertTrue(os.path.isfile(filename))
35
36
37 if __name__ == '__main__':
38     unittest.main()