当前位置: 首页>>代码示例>>Python>>正文


Python sandbox.DirectorySandbox类代码示例

本文整理汇总了Python中apache.aurora.executor.common.sandbox.DirectorySandbox的典型用法代码示例。如果您正苦于以下问题:Python DirectorySandbox类的具体用法?Python DirectorySandbox怎么用?Python DirectorySandbox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DirectorySandbox类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_create_ioerror

def test_create_ioerror(chown):
  chown.side_effect = IOError('Disk is borked')

  with temporary_dir() as d:
    ds = DirectorySandbox(d)
    with pytest.raises(DirectorySandbox.CreationError):
      ds.create()
开发者ID:apache,项目名称:aurora,代码行数:7,代码来源:test_sandbox.py

示例2: test_create_ioerror

def test_create_ioerror(chown):
  chown.side_effect = IOError('Disk is borked')

  with temporary_dir() as d:
    real_path = os.path.join(d, 'sandbox')
    ds = DirectorySandbox(real_path)
    with pytest.raises(DirectorySandbox.CreationError):
      ds.create()
开发者ID:AltanAlpay,项目名称:aurora,代码行数:8,代码来源:test_sandbox.py

示例3: test_create_no_user

def test_create_no_user(*args):
  with temporary_dir() as d:
    ds = DirectorySandbox(d)
    ds.create()
    assert os.path.exists(ds.root)

  for mocked in args:
    mocked.assert_not_called()
开发者ID:apache,项目名称:aurora,代码行数:8,代码来源:test_sandbox.py

示例4: test_create_no_user

def test_create_no_user(*args):
  with temporary_dir() as d:
    real_path = os.path.join(d, 'sandbox')
    ds = DirectorySandbox(real_path)
    ds.create()
    assert os.path.exists(real_path)

  for mocked in args:
    mocked.assert_not_called()
开发者ID:AltanAlpay,项目名称:aurora,代码行数:9,代码来源:test_sandbox.py

示例5: test_destroy_ioerror

def test_destroy_ioerror():
  with temporary_dir() as d:
    ds = DirectorySandbox(d)
    ds.create()

    with mock.patch('shutil.rmtree') as shutil_rmtree:
      shutil_rmtree.side_effect = IOError('What even are you doing?')
      with pytest.raises(DirectorySandbox.DeletionError):
        ds.destroy()
开发者ID:apache,项目名称:aurora,代码行数:9,代码来源:test_sandbox.py

示例6: test_user_does_not_exist

def test_user_does_not_exist(getpwnam):
  getpwnam.side_effect = KeyError('johndoe')

  with temporary_dir() as d:
    ds = DirectorySandbox(d, 'cletus')
    with pytest.raises(DirectorySandbox.CreationError):
      ds.create()

  getpwnam.assert_called_with('cletus')
开发者ID:apache,项目名称:aurora,代码行数:9,代码来源:test_sandbox.py

示例7: test_user_does_not_exist

def test_user_does_not_exist(getpwnam):
    getpwnam.side_effect = KeyError("johndoe")

    with temporary_dir() as d:
        real_path = os.path.join(d, "sandbox")
        ds = DirectorySandbox(real_path, "cletus")
        with pytest.raises(DirectorySandbox.CreationError):
            ds.create()

    getpwnam.assert_called_with("cletus")
开发者ID:bmhatfield,项目名称:aurora,代码行数:10,代码来源:test_sandbox.py

示例8: test_destroy_ioerror

def test_destroy_ioerror():
    with temporary_dir() as d:
        real_path = os.path.join(d, "sandbox")
        ds = DirectorySandbox(real_path)
        ds.create()

        with mock.patch("shutil.rmtree") as shutil_rmtree:
            shutil_rmtree.side_effect = IOError("What even are you doing?")
            with pytest.raises(DirectorySandbox.DeletionError):
                ds.destroy()
开发者ID:bmhatfield,项目名称:aurora,代码行数:10,代码来源:test_sandbox.py

示例9: test_directory_sandbox

def test_directory_sandbox():
  with temporary_dir() as d:
    ds1 = DirectorySandbox(os.path.join(d, 'task1'))
    ds2 = DirectorySandbox(os.path.join(d, 'task2'))
    ds1.create()
    ds2.create()
    assert os.path.exists(ds1.root)
    assert os.path.exists(ds2.root)
    ds1.destroy()
    assert not os.path.exists(ds1.root)
    assert os.path.exists(ds2.root)
    ds2.destroy()
    assert not os.path.exists(ds2.root)
开发者ID:sumanau7,项目名称:incubator-aurora,代码行数:13,代码来源:test_directory_sandbox.py

示例10: test_create

def test_create(chmod, chown, getpwnam, getgrgid):
  getgrgid.return_value.gr_name = 'foo'
  getpwnam.return_value.pw_gid = 123
  getpwnam.return_value.pw_uid = 456

  with temporary_dir() as d:
    real_path = os.path.join(d, 'sandbox')
    ds = DirectorySandbox(real_path, 'cletus')
    ds.create()
    assert os.path.exists(real_path)

  getpwnam.assert_called_with('cletus')
  getgrgid.assert_called_with(123)
  chown.assert_called_with(real_path, 456, 123)
  chmod.assert_called_with(real_path, 0700)
开发者ID:sumanau7,项目名称:incubator-aurora,代码行数:15,代码来源:test_directory_sandbox.py

示例11: test_create

def test_create(chmod, chown, getpwnam, getgrgid):
  getgrgid.return_value.gr_name = 'foo'
  getpwnam.return_value.pw_gid = 123
  getpwnam.return_value.pw_uid = 456

  with temporary_dir() as mesos_dir:
    ds = DirectorySandbox(mesos_dir, 'cletus')
    ds.create()
    assert os.path.exists(ds.root)

  getpwnam.assert_called_with('cletus')
  getgrgid.assert_called_with(123)

  chown.assert_any_call(mesos_dir, 456, 123)
  chown.assert_any_call(ds.root, 456, 123)
  chmod.assert_called_with(ds.root, 0700)
开发者ID:apache,项目名称:aurora,代码行数:16,代码来源:test_sandbox.py


注:本文中的apache.aurora.executor.common.sandbox.DirectorySandbox类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。