forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_run_test_report.py
46 lines (34 loc) · 1.23 KB
/
test_run_test_report.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
import os
import unittest
from typing import Any
from unittest.mock import Mock, patch
import pytest
from pytest import CaptureFixture
from run_test_report import main
class TestRunTestReport(unittest.TestCase):
TEST_MANIFEST_PATH = os.path.join(
os.path.dirname(__file__),
"tests_report_workflow",
"data",
"test_manifest.yml"
)
@pytest.fixture(autouse=True)
def getCapfd(self, capfd: CaptureFixture) -> None:
self.capfd = capfd
@patch("argparse._sys.argv", ["run_test_report.py", "--help"])
def test_usage(self, *mocks: Any) -> None:
with self.assertRaises(SystemExit):
main()
out, _ = self.capfd.readouterr()
self.assertTrue(out.startswith("usage:"))
@patch("argparse._sys.argv", ["run_test_report.py", TEST_MANIFEST_PATH, "-p", "opensearch=foo"])
@patch('run_test_report.TestReportRunner')
def test_main(self, runner_mock: Mock, *mocks: Any) -> None:
main()
runner_mock.assert_called()