Beispiel #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')
Beispiel #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')
Beispiel #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')
Beispiel #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
Beispiel #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')
Beispiel #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()
Beispiel #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')
Beispiel #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')
Beispiel #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')
Beispiel #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')