def test_workspace_not_registered(self): class Exception_(Exception): pass m_exit = self.useFixture(fixtures.MockPatch('sys.exit')).mock # sys.exit must not continue (or exit) m_exit.side_effect = Exception_ workspace = self.getUniqueString() tempest_run = run.TempestRun(app=mock.Mock(), app_args=mock.Mock()) parsed_args = mock.Mock() parsed_args.config_file = [] # Override $HOME so that empty workspace gets created in temp dir. self.useFixture(fixtures.TempHomeDir()) # Force use of the temporary home directory. parsed_args.workspace_path = None # Simulate --workspace argument. parsed_args.workspace = workspace self.assertRaises(Exception_, tempest_run.take_action, parsed_args) exit_msg = m_exit.call_args[0][0] self.assertIn(workspace, exit_msg)
def test_no_config_file_no_workspace_no_state(self): self._setup_test_dirs() tempest_run = run.TempestRun(app=mock.Mock(), app_args=mock.Mock()) parsed_args = mock.Mock() parsed_args.workspace = None parsed_args.state = None parsed_args.list_tests = False parsed_args.config_file = '' with mock.patch('stestr.commands.run_command'): self.assertRaises(SystemExit, tempest_run.take_action, parsed_args)
def test_config_file_workspace_registered(self): self._setup_test_dirs() tempest_run = run.TempestRun(app=mock.Mock(), app_args=mock.Mock()) parsed_args = mock.Mock() parsed_args.workspace = self.name parsed_args.workspace_path = self.store_file parsed_args.state = None parsed_args.list_tests = False parsed_args.config_file = '.stestr.conf' with mock.patch('stestr.commands.run_command') as m: m.return_value = 0 self.assertEqual(0, tempest_run.take_action(parsed_args)) m.assert_called()
def test_config_file_specified(self): self._setup_test_dirs() _, path = tempfile.mkstemp() self.addCleanup(os.remove, path) tempest_run = run.TempestRun(app=mock.Mock(), app_args=mock.Mock()) parsed_args = mock.Mock() parsed_args.workspace = None parsed_args.state = None parsed_args.list_tests = False parsed_args.config_file = path with mock.patch('stestr.commands.run_command') as m: m.return_value = 0 self.assertEqual(0, tempest_run.take_action(parsed_args)) m.assert_called()
def test_config_file_specified(self): # Setup test dirs self.directory = tempfile.mkdtemp(prefix='tempest-unit') self.addCleanup(shutil.rmtree, self.directory) self.test_dir = os.path.join(self.directory, 'tests') os.mkdir(self.test_dir) # Change directory, run wrapper and check result self.addCleanup(os.chdir, os.path.abspath(os.curdir)) os.chdir(self.directory) tempest_run = run.TempestRun(app=mock.Mock(), app_args=mock.Mock()) parsed_args = mock.Mock() parsed_args.workspace = None parsed_args.state = None parsed_args.list_tests = False parsed_args.config_file = '.stestr.conf' with mock.patch('stestr.commands.run_command') as m: m.return_value = 0 self.assertEqual(0, tempest_run.take_action(parsed_args)) m.assert_called()
def setUp(self): super(TestTempestRun, self).setUp() self.run_cmd = run.TempestRun(None, None)
def setUp(self): super(TestConfigPathCheck, self).setUp() self.run_cmd = run.TempestRun(None, None)