You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
catcli/tests/test_find.py

46 lines
1.1 KiB
Python

"""
author: deadc0de6 (https://github.com/deadc0de6)
Copyright (c) 2017, deadc0de6
Basic unittest for find
"""
import unittest
from catcli.catcli import cmd_find
from catcli.noder import Noder
from catcli.catalog import Catalog
from tests.helpers import get_fakecatalog
class TestFind(unittest.TestCase):
def test_find(self):
# init
catalog = Catalog('fake', force=True, debug=False)
top = catalog._restore_json(get_fakecatalog())
noder = Noder()
# create fake args
args = {'<term>': '7544G', '--script': True,
'--verbose': True, '--parent': False,
'--directory': False, '--path': None,
'--format': 'native'}
# try to find something
found = cmd_find(args, noder, top)
self.assertTrue(len(found) > 0)
# try to find something that does not exist
args['<term>'] = 'verynotfoundnote'
found = cmd_find(args, noder, top)
self.assertTrue(len(found) == 0)
def main():
unittest.main()
if __name__ == '__main__':
main()