Exemplo n.º 1
0
class AliasTestCase(unittest.TestCase):
    def setUp(self):
        testutils.clearDatabase()
        self.cmd = AliasCmd()

    def testAdd(self):
        self.cmd.do_a_add("l t_list")
        alias = Config.selectBy(name="ALIASES")[0]
        self.assertEqual(eval(alias.value)["l"], "t_list")
Exemplo n.º 2
0
 def __init__(self):
     Cmd.__init__(self)
     TaskCmd.__init__(self)
     ProjectCmd.__init__(self)
     KeywordCmd.__init__(self)
     AliasCmd.__init__(self)
     ConfCmd.__init__(self)
     self.prompt = "yokadi> "
     self.historyPath = basepaths.getHistoryPath()
     self.loadHistory()
Exemplo n.º 3
0
 def __init__(self):
     Cmd.__init__(self)
     TaskCmd.__init__(self)
     ProjectCmd.__init__(self)
     KeywordCmd.__init__(self)
     AliasCmd.__init__(self)
     ConfCmd.__init__(self)
     self.prompt = "yokadi> "
     self.historyPath = basepaths.getHistoryPath()
     self.loadHistory()
Exemplo n.º 4
0
 def __init__(self):
     Cmd.__init__(self)
     TaskCmd.__init__(self)
     ProjectCmd.__init__(self)
     KeywordCmd.__init__(self)
     AliasCmd.__init__(self)
     ConfCmd.__init__(self)
     self.prompt = "yokadi> "
     self.historyPath = basepaths.getHistoryPath()
     self.loadHistory()
     self.cryptoMgr = cryptutils.YokadiCryptoManager(
     )  # Load shared cryptographic manager
Exemplo n.º 5
0
class AliasTestCase(unittest.TestCase):
    def setUp(self):
        db.connectDatabase("", memoryDatabase=True)
        self.session = db.getSession()
        self.cmd = AliasCmd()

    def testAdd(self):
        self.cmd.do_a_add("l t_list")
        self.cmd.do_a_add("la t_list -a")
        alias = self.session.query(Config).filter_by(name="ALIASES")[0]
        self.assertEqual(eval(alias.value)["l"], "t_list")
        self.cmd.do_a_remove("l")
        self.cmd.do_a_remove("la")
        self.cmd.do_a_remove("unknown")
        self.assertEqual(eval(alias.value), {})
Exemplo n.º 6
0
 def __init__(self):
     Cmd.__init__(self)
     TaskCmd.__init__(self)
     ProjectCmd.__init__(self)
     KeywordCmd.__init__(self)
     AliasCmd.__init__(self)
     ConfCmd.__init__(self)
     self.prompt = "yokadi> "
     self.historyPath = os.getenv("YOKADI_HISTORY")
     if not self.historyPath:
         if os.name == "posix":
             self.historyPath = os.path.join(os.path.expandvars("$HOME"), ".yokadi_history")
         else:
             # Windows location
             self.historyPath = os.path.join(os.path.expandvars("$APPDATA"), ".yokadi_history")
     self.loadHistory()
     self.cryptoMgr = cryptutils.YokadiCryptoManager()  # Load shared cryptographic manager
Exemplo n.º 7
0
Arquivo: main.py Projeto: bport/yokadi
 def __init__(self):
     Cmd.__init__(self)
     TaskCmd.__init__(self)
     ProjectCmd.__init__(self)
     KeywordCmd.__init__(self)
     AliasCmd.__init__(self)
     ConfCmd.__init__(self)
     self.prompt = "yokadi> "
     self.historyPath = os.getenv("YOKADI_HISTORY")
     if not self.historyPath:
         if os.name == "posix":
             self.historyPath = os.path.join(os.path.expandvars("$HOME"),
                                             ".yokadi_history")
         else:
             # Windows location
             self.historyPath = os.path.join(os.path.expandvars("$APPDATA"),
                                             ".yokadi_history")
     self.loadHistory()
     self.cryptoMgr = cryptutils.YokadiCryptoManager(
     )  # Load shared cryptographic manager
Exemplo n.º 8
0
 def setUp(self):
     testutils.clearDatabase()
     self.cmd = AliasCmd()
Exemplo n.º 9
0
 def setUp(self):
     db.connectDatabase("", memoryDatabase=True)
     self.session = db.getSession()
     self.cmd = AliasCmd()
Exemplo n.º 10
0
class AliasTestCase(unittest.TestCase):
    def setUp(self):
        db.connectDatabase("", memoryDatabase=True)
        self.session = db.getSession()
        self.cmd = AliasCmd()

    def testList(self):
        self.cmd.do_a_add("b t_add")
        self.cmd.do_a_add("a t_list")
        out = StringIO()
        with redirect_stdout(out):
            self.cmd.do_a_list("")
            content = out.getvalue()
            self.assertEqual(content,
                             colors.BOLD + "a".ljust(10) + colors.RESET + "=> t_list\n"
                             + colors.BOLD + "b".ljust(10) + colors.RESET + "=> t_add\n")

    def testList_empty(self):
        out = StringIO()
        with redirect_stdout(out):
            self.cmd.do_a_list("")
            content = out.getvalue()
            self.assertTrue("No alias defined" in content)

    def testAdd(self):
        self.cmd.do_a_add("l t_list")
        self.cmd.do_a_add("la t_list -a")
        aliases = Alias.getAsDict(self.session)
        self.assertEqual(aliases["l"], "t_list")
        self.cmd.do_a_remove("l")
        self.cmd.do_a_remove("la")
        self.cmd.do_a_remove("unknown")
        aliases = Alias.getAsDict(self.session)
        self.assertEqual(aliases, {})

    def testEditName(self):
        self.cmd.do_a_add("l t_list")

        tui.addInputAnswers("ls")
        self.cmd.do_a_edit_name("l")

        aliases = Alias.getAsDict(self.session)
        self.assertEqual(aliases["ls"], "t_list")

    def testEditCommand(self):
        self.cmd.do_a_add("l t_list")

        tui.addInputAnswers("foo")
        self.cmd.do_a_edit_command("l")

        aliases = Alias.getAsDict(self.session)
        self.assertEqual(aliases["l"], "foo")
Exemplo n.º 11
0
 def setUp(self):
     db.connectDatabase("", memoryDatabase=True)
     self.session = db.getSession()
     self.cmd = AliasCmd()
Exemplo n.º 12
0
class AliasTestCase(unittest.TestCase):
    def setUp(self):
        db.connectDatabase("", memoryDatabase=True)
        self.session = db.getSession()
        self.cmd = AliasCmd()

    def testList(self):
        self.cmd.do_a_add("b t_add")
        self.cmd.do_a_add("a t_list")
        out = StringIO()
        with redirect_stdout(out):
            self.cmd.do_a_list("")
            content = out.getvalue()
            self.assertEqual(
                content, C.BOLD + "a".ljust(10) + C.RESET + "=> t_list\n" +
                C.BOLD + "b".ljust(10) + C.RESET + "=> t_add\n")

    def testList_empty(self):
        out = StringIO()
        with redirect_stdout(out):
            self.cmd.do_a_list("")
            content = out.getvalue()
            self.assertTrue("No alias defined" in content)

    def testAdd(self):
        self.cmd.do_a_add("l t_list")
        self.cmd.do_a_add("la t_list -a")
        aliases = Alias.getAsDict(self.session)
        self.assertEqual(aliases["l"], "t_list")
        self.cmd.do_a_remove("l")
        self.cmd.do_a_remove("la")
        self.cmd.do_a_remove("unknown")
        aliases = Alias.getAsDict(self.session)
        self.assertEqual(aliases, {})

    def testEditName(self):
        self.cmd.do_a_add("l t_list")

        tui.addInputAnswers("ls")
        self.cmd.do_a_edit_name("l")

        aliases = Alias.getAsDict(self.session)
        self.assertEqual(aliases["ls"], "t_list")

    def testEditCommand(self):
        self.cmd.do_a_add("l t_list")

        tui.addInputAnswers("foo")
        self.cmd.do_a_edit_command("l")

        aliases = Alias.getAsDict(self.session)
        self.assertEqual(aliases["l"], "foo")