Skip to content

Commit

Permalink
add utils/tests/test_scanner.py
Browse files Browse the repository at this point in the history
and test_run_unit_test in test_remote.py

Signed-off-by: Vallari Agrawal <[email protected]>
  • Loading branch information
VallariAg committed Oct 17, 2023
1 parent a0224e7 commit 27ddeeb
Show file tree
Hide file tree
Showing 5 changed files with 248 additions and 73 deletions.
19 changes: 19 additions & 0 deletions teuthology/orchestra/test/test_remote.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from mock import patch, Mock, MagicMock
from pytest import raises

from io import BytesIO

from teuthology.orchestra import remote
from teuthology.orchestra import opsys
from teuthology.orchestra.run import RemoteProcess
from teuthology.exceptions import CommandFailedError, UnitTestError


class TestRemote(object):
Expand Down Expand Up @@ -66,6 +68,23 @@ def test_run(self):
assert result is proc
assert result.remote is rem

@patch('teuthology.util.scanner.UnitTestScanner.scan_and_write')
def test_run_unit_test(self, m_scan_and_write):
m_transport = MagicMock()
m_transport.getpeername.return_value = ('name', 22)
self.m_ssh.get_transport.return_value = m_transport
m_run = MagicMock(name="run", side_effect=CommandFailedError('mocked error', 1, 'smithi'))
args = [
'something',
'more',
]
rem = remote.Remote(name='[email protected]', ssh=self.m_ssh)
rem._runner = m_run
m_scan_and_write.return_value = "Error Message"
with raises(UnitTestError) as exc:
rem.run_unit_test(args=args, xml_path_regex="xml_path", output_yaml="yaml_path")
assert str(exc.value) == "Unit test failed on smithi with status 1: 'Error Message'"

def test_hostname(self):
m_transport = MagicMock()
m_transport.getpeername.return_value = ('name', 22)
Expand Down
Loading

0 comments on commit 27ddeeb

Please sign in to comment.