def testAliasPluginOneCommnand(self): self.conf['plugins']['alias'] = {'print': 'open -w lpppp'} self.plugin = AliasPlugin(self.conf) self.assertEqual(len(self.plugin.aliases), 1) self.assertEqual(type(self.plugin.aliases[0]), CommandAlias) self.assertEqual(self.plugin.aliases[0].name, 'print') self.assertEqual(self.plugin.aliases[0].definition, 'open -w lpppp')
def testAliasPluginTwoCommnands(self): self.conf['plugins']['alias'] = { 'print': 'open -w lpppp', 'count': '!pubs list -k | wc -l' } self.plugin = AliasPlugin(self.conf) self.assertEqual(len(self.plugin.aliases), 2)
def testAliasPluginOneShell(self): self.conf['plugins']['alias'] = {'count': '!pubs list -k | wc -l'} self.plugin = AliasPlugin(self.conf) self.assertEqual(len(self.plugin.aliases), 1) self.assertEqual(type(self.plugin.aliases[0]), ShellAlias) self.assertEqual(self.plugin.aliases[0].name, 'count') self.assertEqual(self.plugin.aliases[0].definition, 'pubs list -k | wc -l')
def testAliasPluginNestedDefinitionType(self): self.conf['plugins']['alias'] = {'print': {'description': 'print this', 'command': 'open -w lpppp'}} self.plugin = AliasPlugin(self.conf) self.assertEqual(len(self.plugin.aliases), 1) self.assertEqual(type(self.plugin.aliases[0]), CommandAlias) self.assertEqual(self.plugin.aliases[0].name, 'print') self.assertEqual(self.plugin.aliases[0].description, 'print this') self.assertEqual(self.plugin.aliases[0].definition, 'open -w lpppp')
def testAliasPluginNestedDefinitionNoDescription(self): self.conf['plugins']['alias'] = {'print': {'command': 'open -w lpppp'}} self.plugin = AliasPlugin(self.conf, None) self.assertEqual(len(self.plugin.aliases), 1) self.assertEqual(type(self.plugin.aliases[0]), CommandAlias) self.assertEqual(self.plugin.aliases[0].name, 'print') self.assertEqual(self.plugin.aliases[0].description, 'user alias for `open -w lpppp`') self.assertEqual(self.plugin.aliases[0].definition, 'open -w lpppp')
def testAliasPluginWrongDefinitionOrder(self): self.conf['plugins']['alias'] = {'print': {'description': 'print this', 'command': 'open -w lpppp', 'count': '!pubs list -k | wc -l'}} self.plugin = AliasPlugin(self.conf) self.assertEqual(len(self.plugin.aliases), 1) self.assertEqual(type(self.plugin.aliases[0]), CommandAlias) self.assertEqual(self.plugin.aliases[0].name, 'print') self.assertEqual(self.plugin.aliases[0].description, 'print this') self.assertEqual(self.plugin.aliases[0].definition, 'open -w lpppp')
def testAliasPluginMixedDefinitionTypes(self): self.conf['plugins']['alias'] = {'print': {'description': 'print this', 'command': 'open -w lpppp'}, 'count': '!pubs list -k | wc -l'} self.plugin = AliasPlugin(self.conf) self.plugin.aliases = sorted(self.plugin.aliases, key=lambda a: a.name) self.assertEqual(len(self.plugin.aliases), 2) self.assertEqual(type(self.plugin.aliases[1]), CommandAlias) self.assertEqual(type(self.plugin.aliases[0]), ShellAlias) self.assertEqual(self.plugin.aliases[0].name, 'count') self.assertEqual(self.plugin.aliases[0].description, 'user alias for `pubs list -k | wc -l`') self.assertEqual(self.plugin.aliases[0].definition, 'pubs list -k | wc -l') self.assertEqual(self.plugin.aliases[1].name, 'print') self.assertEqual(self.plugin.aliases[1].description, 'print this') self.assertEqual(self.plugin.aliases[1].definition, 'open -w lpppp')
def testAliasPluginCreated(self): self.plugin = AliasPlugin(self.conf)