Example #1
0
class TestShell(unittest.TestCase):
    layer = ConfigLayer

    def setUp(self):
        self._shell = Withlist()

    def test_namespace(self):
        args = FakeArgs()
        args.interactive = True
        with patch.object(self._shell, '_start_python') as mock:
            self._shell.process(args)
        self.assertEqual(mock.call_count, 1)
        # Don't test that all names are available, just a few choice ones.
        positional, keywords = mock.call_args
        namespace = positional[0]
        self.assertIn('getUtility', namespace)
        self.assertIn('IArchiver', namespace)
        self.assertEqual(namespace['IUserManager'], IUserManager)

    @configuration('shell', banner='my banner')
    def test_banner(self):
        args = FakeArgs()
        args.interactive = True
        with patch('mailman.commands.cli_withlist.interact') as mock:
            self._shell.process(args)
        self.assertEqual(mock.call_count, 1)
        positional, keywords = mock.call_args
        self.assertEqual(keywords['banner'], 'my banner\n')

    @unittest.skipUnless(has_readline, 'readline module is not available')
    @configuration('shell', history_file='$var_dir/history.py')
    def test_history_file(self):
        args = FakeArgs()
        args.interactive = True
        with patch('mailman.commands.cli_withlist.interact'):
            self._shell.process(args)
        history_file = os.path.join(config.VAR_DIR, 'history.py')
        self.assertTrue(os.path.exists(history_file))
Example #2
0
class TestShell(unittest.TestCase):
    layer = ConfigLayer

    def setUp(self):
        self._shell = Withlist()

    def test_namespace(self):
        args = FakeArgs()
        args.interactive = True
        with patch.object(self._shell, '_start_python') as mock:
            self._shell.process(args)
        self.assertEqual(mock.call_count, 1)
        # Don't test that all names are available, just a few choice ones.
        positional, keywords = mock.call_args
        namespace = positional[0]
        self.assertIn('getUtility', namespace)
        self.assertIn('IArchiver', namespace)
        self.assertEqual(namespace['IUserManager'], IUserManager)

    @configuration('shell', banner='my banner')
    def test_banner(self):
        args = FakeArgs()
        args.interactive = True
        with patch('mailman.commands.cli_withlist.interact') as mock:
            self._shell.process(args)
        self.assertEqual(mock.call_count, 1)
        positional, keywords = mock.call_args
        self.assertEqual(keywords['banner'], 'my banner\n')

    @unittest.skipUnless(has_readline, 'readline module is not available')
    @configuration('shell', history_file='$var_dir/history.py')
    def test_history_file(self):
        args = FakeArgs()
        args.interactive = True
        with patch('mailman.commands.cli_withlist.interact'):
            self._shell.process(args)
        history_file = os.path.join(config.VAR_DIR, 'history.py')
        self.assertTrue(os.path.exists(history_file))
Example #3
0
 def setUp(self):
     self._shell = Withlist()
Example #4
0
 def setUp(self):
     self._shell = Withlist()