Beispiel #1
0
 def test_printer_implented(self):
     """Tests that calling printer and return value of base exception
     """
     base_exception = AdamaError('Base exception')
     # print_error should be implemented
     self.assertRaises(NotImplementedError, base_exception.print_error)
     assert no_shell_printing(base_exception)() == 1
Beispiel #2
0
    def test_raising_order_error(self):
        """Tests that an error during an order execution raised an OrderError
        exception and checks the returned value, message and representation of
    an instance
        """
        with self.assertRaises(OrderError) as order_error:
            call_order('adama', 'create_program')
        exception = order_error.exception
        # error printed on shell
        assert exception.print_error() == 'The create_program order has one \
required argument\nUsage: adama create_program [options] module\n'
        #  representation
        assert repr(exception) == '<OrderError: create_program>'
        # returned value
        assert no_shell_printing(exception)() == 12
Beispiel #3
0
    Testing the capability of the library to parse and deal with arguments
    and options : showing help, direct launch, launching through command line,
    dealing with problem and exception

"""

import unittest

from adama.tests import TestBaseOrders, no_shell_printing, \
    encapsulate_test_with_syspath
from adama import sir_yes_sir, call_order
from adama.exceptions import UnknownOrderError


# disables the standard output printing
_sir_yes_sir = no_shell_printing(sir_yes_sir)


class TestShellHelp(TestBaseOrders):
    """Tests the help message and the way they are displayed
    """

    def test_no_args(self):
        """No argument shell return
        """
        assert _sir_yes_sir(module=self.module, argv=[self.command]) == 1

    def test_global_help(self):
        """Global help shell return
        """
        assert _sir_yes_sir(module=self.module, argv=[self.command, 'help']) \