def test_load_cmd(self): # Make sure _load_cmd will always do nothing to a base cmd for cmd_name, cmd_ref in BASE_CMDS.iteritems(): result = self.target._load_cmd(cmd_name, cmd_ref) self.assertTrue(isOttoCmd(result)) # Make sure all refs for installed packs are paths... self.target.load_pack(PACK_NAME, PACK_DIR) test_pack = self.target.cmds_by_pack[PACK_NAME] for cmd_name, cmd_ref in test_pack.iteritems(): self.assertTrue(isfile(cmd_ref)) # ... and that they return from _load_cmd as an OttoCmd result = self.target._load_cmd(cmd_name, cmd_ref) self.assertTrue(isOttoCmd(result))
import unittest from os.path import dirname, join, isfile from tempfile import NamedTemporaryFile as TF from otto.config import CmdStore from otto.cmds import BASE_CMDS from otto.utils import isOttoCmd TEST_DIR = dirname(__file__) DEFAULT_MAP = map = { 'base': BASE_CMDS.keys(), } PACK_NAME = 'test' PACK_DIR = join(TEST_DIR, '.otto/test') PACK_MAP = { PACK_NAME: [ 'test1', 'test2', ], } class TestCmdStore(unittest.TestCase): @classmethod def setUpClass(cls): from otto.utils import shell, ChangePath, info info("Setting up CmdStore tests...") with ChangePath('otto/test/'): shell('otto dr')