示例#1
0
 def test_guestfs_conn_ro_expand_wrong_var(self, mock_gfs, monkeypatch):
     monkeypatch.delenv('SOME_PATH', raising=False)
     with guestfs_tools.guestfs_conn_ro(disk='$SOME_PATH/file') as conn:
         assert conn.add_drive_ro.call_args == call('$SOME_PATH/file')
示例#2
0
 def test_guestfs_conn_ro_env_backend(self, monkeypatch, mock_gfs):
     monkeypatch.setenv('LIBGUESTFS_BACKEND', 'libvirt')
     with guestfs_tools.guestfs_conn_ro(disk='dummy') as conn:
         assert conn.set_backend.call_args == call('libvirt')
示例#3
0
 def test_guestfs_conn_ro_expand_vars(self, mock_gfs, monkeypatch):
     expanded_path = '/some/path'
     monkeypatch.setenv('SOME_PATH', expanded_path)
     with guestfs_tools.guestfs_conn_ro(disk='$SOME_PATH/file') as conn:
         assert conn.add_drive_ro.call_args == call('/some/path/file')
示例#4
0
 def test_guestfs_conn_ro_error(self, mock_gfs):
     mock_gfs.return_value.launch.side_effect = RuntimeError('mocking')
     with pytest.raises(guestfs_tools.GuestFSError):
         with guestfs_tools.guestfs_conn_ro(disk='dummy'):
             pass
示例#5
0
 def test_guestfs_conn_ro_fallback_backend(self, mock_gfs):
     with guestfs_tools.guestfs_conn_ro(disk='dummy') as conn:
         assert conn.set_backend.call_args == call('direct')
示例#6
0
 def test_guestfs_conn_ro_teardown(self, mock_gfs):
     with guestfs_tools.guestfs_conn_ro(disk='dummy') as conn:
         pass
     assert call.add_drive_ro('dummy') in conn.mock_calls
     assert conn.mock_calls[-1] == call.close()
     assert conn.mock_calls[-2] == call.shutdown()
示例#7
0
 def test_guestfs_conn_ro_expand_wrong_var(self, mock_gfs, monkeypatch):
     monkeypatch.delenv('SOME_PATH', raising=False)
     with guestfs_tools.guestfs_conn_ro(disk='$SOME_PATH/file') as conn:
         assert conn.add_drive_ro.call_args == call('$SOME_PATH/file')
示例#8
0
 def test_guestfs_conn_ro_expand_vars(self, mock_gfs, monkeypatch):
     expanded_path = '/some/path'
     monkeypatch.setenv('SOME_PATH', expanded_path)
     with guestfs_tools.guestfs_conn_ro(disk='$SOME_PATH/file') as conn:
         assert conn.add_drive_ro.call_args == call('/some/path/file')
示例#9
0
 def test_guestfs_conn_ro_env_backend(self, monkeypatch, mock_gfs):
     monkeypatch.setenv('LIBGUESTFS_BACKEND', 'libvirt')
     with guestfs_tools.guestfs_conn_ro(disk='dummy') as conn:
         assert conn.set_backend.call_args == call('libvirt')
示例#10
0
 def test_guestfs_conn_ro_fallback_backend(self, mock_gfs):
     with guestfs_tools.guestfs_conn_ro(disk='dummy') as conn:
         assert conn.set_backend.call_args == call('direct')