Example #1
0
 def test_no_arg(self):
     """No argument passed to the order
     """
     with self.assertRaises(OrderError) as order_error:
         call_order('adama', 'create_order')
     exception = order_error.exception
     assert exception.message == 'The create_order order has two required \
Example #2
0
 def test_no_command_name(self):
     """Tests creating a command with no name defined
     """
     call_order('adama', 'create_program', self.module, pythonpath='/tmp',
         path=self.destination, name='')
     self.assertTrue(self._isfile(self.module))
     self._remove_from_syspath()
Example #3
0
 def test_no_orders_module(self):
     """The orders module is absent
     """
     shutil.rmtree(self.orders_path)
     call_order('adama', 'create_order', self.module, 'no_module',
         pythonpath='/tmp', name=self.command)
     self.assertTrue(self._isfile('no_module.py'))
     self._remove_from_syspath()
Example #4
0
 def test_in_syspath(self):
     """Tests searching module with no pythonpath add and module in syspath
     """
     self._add_to_syspath()
     call_order('adama', 'create_program', self.module, name=self.command,
         pythonpath='', path=self.destination)
     self.assertTrue(self._isfile(self.command))
     self._remove_from_syspath()
Example #5
0
 def test_in_syspath(self):
     """Tests creating orders in a package that is present in syspath
     """
     self._add_to_syspath()
     call_order('adama', 'create_order', self.module, 'test', pythonpath='',
         name=self.command)
     self.assertTrue(self._isfile('test.py'))
     self._remove_from_syspath()
Example #6
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
Example #7
0
 def test_executing_order(self):
     """Order executed function return
     """
     assert call_order(self.module, 'add') == 0