Esempio n. 1
0
    def setUp(self):
        super(TempestLogWrappersTestCase, self).setUp()
        verifier = mock.MagicMock()
        verifier.parse_results.return_value = mock.MagicMock(total={"time": 0},
                                                             tests={})

        context = test.get_test_context()
        context.update({"tmp_results_dir": "/tmp/dir", "verifier": verifier})
        self.scenario = tempest.SingleTest(context)
        self.scenario._add_atomic_actions = mock.MagicMock()
Esempio n. 2
0
    def test_func_time_result_is_string(self):
        verifier = mock.MagicMock()
        verifier.parse_results.return_value = mock.MagicMock(
            total={"time": "0.1"}, tests={})
        context = test.get_test_context()
        context.update({"tmp_results_dir": "/tmp/dir", "verifier": verifier})
        scenario = tempest.SingleTest(context)

        target_func = mock.MagicMock()
        target_func.__name__ = "target_func"
        func = utils.tempest_log_wrapper(target_func)

        func(scenario)
        self.assertEqual(0.1, scenario._atomic_actions["test_execution"])
Esempio n. 3
0
    def test_single_test_without_prefix(self, mock_tempest_resources_context,
                                        mock_subprocess, mock_tempfile,
                                        mock_isfile):
        scenario = tempest.SingleTest(self.context)
        scenario._add_atomic_actions = mock.MagicMock()

        mock_tempfile.NamedTemporaryFile().name = "/dev/null"

        scenario.run("network")

        expected_call = self.get_tests_launcher_cmd(["tempest.api.network"])
        mock_subprocess.check_call.assert_called_once_with(
            expected_call,
            cwd=self.verifier.path(),
            env=self.verifier.env,
            shell=True)