Ejemplo n.º 1
0
def test_get_contents_ok(loader):
    with patch('ansible_runner.loader.open') as mock_open:
        handler = BytesIO()
        handler.write(b"test string")
        handler.seek(0)

        mock_open.return_value.__enter__.return_value = handler

        res = loader.get_contents('/tmp')
        assert res == b'test string'
Ejemplo n.º 2
0
def test_get_contents_ok(loader, mocker):
    mock_open = mocker.patch('codecs.open')

    handler = BytesIO()
    handler.write(b"test string")
    handler.seek(0)

    mock_open.return_value.__enter__.return_value = handler

    res = loader.get_contents('/tmp')
    assert res == b'test string'
Ejemplo n.º 3
0
def test_get_contents_exception(loader):
    with raises(ConfigurationError):
        loader.get_contents('/tmp')
Ejemplo n.º 4
0
def test_get_contents_invalid_path(loader):
    with raises(ConfigurationError):
        loader.get_contents('/tmp/invalid')
Ejemplo n.º 5
0
def test_get_contents_exception(loader, tmp_path):
    with raises(ConfigurationError):
        loader.get_contents(tmp_path.as_posix())
Ejemplo n.º 6
0
def test_get_contents_invalid_path(loader, tmp_path):
    with raises(ConfigurationError):
        loader.get_contents(tmp_path.joinpath('invalid').as_posix())