當前位置: 首頁>>代碼示例>>Python>>正文


Python DirectorySandbox.create方法代碼示例

本文整理匯總了Python中apache.aurora.executor.common.sandbox.DirectorySandbox.create方法的典型用法代碼示例。如果您正苦於以下問題:Python DirectorySandbox.create方法的具體用法?Python DirectorySandbox.create怎麽用?Python DirectorySandbox.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在apache.aurora.executor.common.sandbox.DirectorySandbox的用法示例。


在下文中一共展示了DirectorySandbox.create方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_create_ioerror

# 需要導入模塊: from apache.aurora.executor.common.sandbox import DirectorySandbox [as 別名]
# 或者: from apache.aurora.executor.common.sandbox.DirectorySandbox import create [as 別名]
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,代碼行數:9,代碼來源:test_sandbox.py

示例2: test_create_ioerror

# 需要導入模塊: from apache.aurora.executor.common.sandbox import DirectorySandbox [as 別名]
# 或者: from apache.aurora.executor.common.sandbox.DirectorySandbox import create [as 別名]
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,代碼行數:10,代碼來源:test_sandbox.py

示例3: test_create_no_user

# 需要導入模塊: from apache.aurora.executor.common.sandbox import DirectorySandbox [as 別名]
# 或者: from apache.aurora.executor.common.sandbox.DirectorySandbox import create [as 別名]
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,代碼行數:10,代碼來源:test_sandbox.py

示例4: test_create_no_user

# 需要導入模塊: from apache.aurora.executor.common.sandbox import DirectorySandbox [as 別名]
# 或者: from apache.aurora.executor.common.sandbox.DirectorySandbox import create [as 別名]
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,代碼行數:11,代碼來源:test_sandbox.py

示例5: test_destroy_ioerror

# 需要導入模塊: from apache.aurora.executor.common.sandbox import DirectorySandbox [as 別名]
# 或者: from apache.aurora.executor.common.sandbox.DirectorySandbox import create [as 別名]
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,代碼行數:11,代碼來源:test_sandbox.py

示例6: test_user_does_not_exist

# 需要導入模塊: from apache.aurora.executor.common.sandbox import DirectorySandbox [as 別名]
# 或者: from apache.aurora.executor.common.sandbox.DirectorySandbox import create [as 別名]
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,代碼行數:11,代碼來源:test_sandbox.py

示例7: test_user_does_not_exist

# 需要導入模塊: from apache.aurora.executor.common.sandbox import DirectorySandbox [as 別名]
# 或者: from apache.aurora.executor.common.sandbox.DirectorySandbox import create [as 別名]
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,代碼行數:12,代碼來源:test_sandbox.py

示例8: test_destroy_ioerror

# 需要導入模塊: from apache.aurora.executor.common.sandbox import DirectorySandbox [as 別名]
# 或者: from apache.aurora.executor.common.sandbox.DirectorySandbox import create [as 別名]
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,代碼行數:12,代碼來源:test_sandbox.py

示例9: test_directory_sandbox

# 需要導入模塊: from apache.aurora.executor.common.sandbox import DirectorySandbox [as 別名]
# 或者: from apache.aurora.executor.common.sandbox.DirectorySandbox import create [as 別名]
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,代碼行數:15,代碼來源:test_directory_sandbox.py

示例10: test_create

# 需要導入模塊: from apache.aurora.executor.common.sandbox import DirectorySandbox [as 別名]
# 或者: from apache.aurora.executor.common.sandbox.DirectorySandbox import create [as 別名]
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,代碼行數:17,代碼來源:test_directory_sandbox.py

示例11: test_create

# 需要導入模塊: from apache.aurora.executor.common.sandbox import DirectorySandbox [as 別名]
# 或者: from apache.aurora.executor.common.sandbox.DirectorySandbox import create [as 別名]
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,代碼行數:18,代碼來源:test_sandbox.py


注:本文中的apache.aurora.executor.common.sandbox.DirectorySandbox.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。