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

55 lines
1.3 KiB
Python
Raw Normal View History

2017-12-14 18:37:31 +00:00
"""
author: deadc0de6 (https://github.com/deadc0de6)
Copyright (c) 2017, deadc0de6
Basic unittest for rm
"""
import unittest
from catcli.catcli import *
from catcli.noder import Noder
from catcli.walker import Walker
from catcli.catalog import Catalog
from tests.helpers import *
class TestRm(unittest.TestCase):
def test_rm(self):
# init
path = 'fake'
self.addCleanup(clean, path)
catalog = Catalog(path, force=True, verbose=False)
top = catalog._restore_json(get_fakecatalog())
noder = Noder()
# create fake args dict
2017-12-14 19:02:24 +00:00
args = {'<path>': '', '--recursive': False,
'--verbose': True}
2017-12-14 18:37:31 +00:00
# list files and make sure there are children
args['<path>'] = ''
found = cmd_ls(args, noder, top)
self.assertTrue(len(found) > 0)
self.assertTrue(len(top.children) == 1)
# rm a not existing storage
args['<storage>'] = 'abc'
top = cmd_rm(args, noder, catalog, top)
# rm a storage
args['<storage>'] = 'tmpdir'
top = cmd_rm(args, noder, catalog, top)
# ensure there no children anymore
self.assertTrue(len(top.children) == 0)
def main():
unittest.main()
if __name__ == '__main__':
main()