def test_stacktrace_when_debug_enabled(self):
     with mock.patch.object(traceback, 'print_exc') as mock_print_exc:
         try:
             openstack_shell.main()
         except SystemExit:
             pass
         self.assertTrue(mock_print_exc.called)
예제 #2
0
 def test_shell_keyboard_interrupt(self, mock_glance_shell):
     # Ensure that exit code is 130 for KeyboardInterrupt
     try:
         mock_glance_shell.side_effect = KeyboardInterrupt()
         openstack_shell.main()
     except SystemExit as ex:
         self.assertEqual(130, ex.code)
예제 #3
0
 def test_shell_keyboard_interrupt(self, mock_glance_shell):
     # Ensure that exit code is 130 for KeyboardInterrupt
     try:
         mock_glance_shell.side_effect = KeyboardInterrupt()
         openstack_shell.main()
     except SystemExit as ex:
         self.assertEqual(130, ex.code)
예제 #4
0
 def test_stacktrace_when_debug_enabled(self):
     with mock.patch.object(traceback, 'print_exc') as mock_print_exc:
         try:
             openstack_shell.main()
         except SystemExit:
             pass
         self.assertTrue(mock_print_exc.called)
예제 #5
0
    def test_main_noargs(self):
        # Ensure that main works with no command-line arguments
        try:
            openstack_shell.main()
        except SystemExit:
            self.fail('Unexpected SystemExit')

        # We expect the normal usage as a result
        self.assertIn('Command-line interface to the OpenStack Images API',
                      sys.stdout.getvalue())
예제 #6
0
    def test_main_noargs(self):
        # Ensure that main works with no command-line arguments
        try:
            openstack_shell.main()
        except SystemExit:
            self.fail('Unexpected SystemExit')

        # We expect the normal usage as a result
        self.assertIn('Command-line interface to the OpenStack Images API',
                      sys.stdout.getvalue())
 def test_stacktrace_when_debug_enabled_by_env(self):
     old_environment = os.environ.copy()
     os.environ = {'GLANCECLIENT_DEBUG': '1'}
     try:
         with mock.patch.object(traceback, 'print_exc') as mock_print_exc:
             try:
                 openstack_shell.main()
             except SystemExit:
                 pass
             self.assertTrue(mock_print_exc.called)
     finally:
         os.environ = old_environment
예제 #8
0
 def test_stacktrace_when_debug_enabled_by_env(self):
     old_environment = os.environ.copy()
     os.environ = {'GLANCECLIENT_DEBUG': '1'}
     try:
         with mock.patch.object(traceback, 'print_exc') as mock_print_exc:
             try:
                 openstack_shell.main()
             except SystemExit:
                 pass
             self.assertTrue(mock_print_exc.called)
     finally:
         os.environ = old_environment
예제 #9
0
    def test_main_noargs(self):
        # Ensure that main works with no command-line arguments
        try:
            openstack_shell.main()
        except SystemExit:
            self.fail('Unexpected SystemExit')

        # We expect the normal v2 usage as a result
        expected = [
            'Command-line interface to the OpenStack Images API', 'image-list',
            'image-deactivate', 'location-add'
        ]
        for output in expected:
            self.assertIn(output, sys.stdout.getvalue())
예제 #10
0
    def test_main_noargs(self):
        # Ensure that main works with no command-line arguments
        try:
            openstack_shell.main()
        except SystemExit:
            self.fail('Unexpected SystemExit')

        # We expect the normal v2 usage as a result
        expected = ['Command-line interface to the OpenStack Images API',
                    'image-list',
                    'image-deactivate',
                    'location-add']
        for output in expected:
            self.assertIn(output,
                          sys.stdout.getvalue())