2
1
mirror of https://github.com/deadc0de6/catcli synced 2024-11-15 18:14:01 +00:00
catcli/tests/test_graph.py

46 lines
982 B
Python
Raw Normal View History

2017-12-14 19:06:16 +00:00
"""
author: deadc0de6 (https://github.com/deadc0de6)
Copyright (c) 2017, deadc0de6
2017-12-14 19:09:04 +00:00
Basic unittest for graph
2017-12-14 19:06:16 +00:00
"""
import unittest
2018-09-27 06:05:13 +00:00
import tempfile
import os
2017-12-14 19:06:16 +00:00
2019-02-16 12:54:00 +00:00
from catcli.catcli import cmd_graph
2017-12-14 19:06:16 +00:00
from catcli.noder import Noder
from catcli.catalog import Catalog
2019-02-16 12:54:00 +00:00
from tests.helpers import clean, get_fakecatalog
2017-12-14 19:06:16 +00:00
class TestGraph(unittest.TestCase):
def test_graph(self):
# init
path = 'fake'
2018-09-27 06:05:13 +00:00
gpath = tempfile.gettempdir() + os.sep + 'graph.dot'
2017-12-14 19:06:16 +00:00
self.addCleanup(clean, path)
self.addCleanup(clean, gpath)
2020-03-27 13:33:06 +00:00
catalog = Catalog(path, force=True, debug=False)
2017-12-14 19:06:16 +00:00
top = catalog._restore_json(get_fakecatalog())
noder = Noder()
# create fake args dict
args = {'<path>': gpath, '--verbose': True}
# create the graph
cmd_graph(args, noder, top)
# ensure file exists
self.assertTrue(os.path.exists(gpath))
def main():
unittest.main()
if __name__ == '__main__':
main()