コード例 #1
0
ファイル: proxyfs_test.py プロジェクト: ziq211/hue
def test_fs_selection():
  make_logged_in_client(username='******', groupname='default', recreate=True, is_superuser=False)
  user = User.objects.get(username='******')
  with patch('desktop.lib.fs.ProxyFS._has_access') as _has_access:
    _has_access.return_value = True

    s3fs, adls, hdfs, abfs, gs = MagicMock(), MagicMock(), MagicMock(), MagicMock(), MagicMock()
    proxy_fs = ProxyFS({'s3a': wrapper(s3fs), 'hdfs': wrapper(hdfs), 'adl': wrapper(adls), 'abfs': wrapper(abfs), 'gs': wrapper(gs)}, 'hdfs')
    proxy_fs.setuser(user)

    proxy_fs.isdir('s3a://bucket/key')
    s3fs.isdir.assert_called_once_with('s3a://bucket/key')
    assert_false(hdfs.isdir.called)

    proxy_fs.isfile('hdfs://localhost:42/user/alice/file')
    hdfs.isfile.assert_called_once_with('hdfs://localhost:42/user/alice/file')
    assert_false(s3fs.isfile.called)

    proxy_fs.isdir('adl://net/key')
    adls.isdir.assert_called_once_with('adl://net/key')
    assert_false(hdfs.isdir.called)

    proxy_fs.isdir('abfs://net/key')
    abfs.isdir.assert_called_once_with('abfs://net/key')
    assert_false(hdfs.isdir.called)

    proxy_fs.isdir('gs://net/key')
    gs.isdir.assert_called_once_with('gs://net/key')
    assert_false(hdfs.isdir.called)

    assert_raises(IOError, proxy_fs.stats, 'ftp://host')
コード例 #2
0
ファイル: proxyfs_test.py プロジェクト: dulems/hue-1
def test_fs_selection():
  try:
    from mock import MagicMock
  except ImportError:
    raise SkipTest("Skips until HUE-2947 is resolved")

  make_logged_in_client(username='******', groupname='default', recreate=True, is_superuser=False)
  user = User.objects.get(username='******')
  add_permission('test', 'has_s3', permname='s3_access', appname='filebrowser')

  s3fs, hdfs = MagicMock(), MagicMock()
  proxy_fs = ProxyFS({'s3a': s3fs, 'hdfs': hdfs}, 'hdfs')
  proxy_fs.setuser(user)

  proxy_fs.isdir('s3a://bucket/key')
  s3fs.isdir.assert_called_once_with('s3a://bucket/key')
  assert_false(hdfs.isdir.called)

  proxy_fs.isfile('hdfs://localhost:42/user/alice/file')
  hdfs.isfile.assert_called_once_with('hdfs://localhost:42/user/alice/file')
  assert_false(s3fs.isfile.called)

  proxy_fs.open('/user/alice/file')
  hdfs.open.assert_called_once_with('/user/alice/file')
  assert_false(s3fs.open.called)

  assert_raises(IOError, proxy_fs.stats, 'ftp://host')
  assert_raises(IOError, proxy_fs.stats, 's3//bucket/key')
コード例 #3
0
ファイル: proxyfs_test.py プロジェクト: CaeserNieh/hue
def test_fs_selection():
  try:
    from mock import MagicMock
  except ImportError:
    raise SkipTest("Skips until HUE-2947 is resolved")

  s3fs, hdfs = MagicMock(), MagicMock()
  proxy_fs = ProxyFS({'s3a': s3fs, 'hdfs': hdfs}, 'hdfs')

  proxy_fs.isdir('s3a://bucket/key')
  s3fs.isdir.assert_called_once_with('s3a://bucket/key')
  assert_false(hdfs.isdir.called)

  proxy_fs.isfile('hdfs://localhost:42/user/alice/file')
  hdfs.isfile.assert_called_once_with('hdfs://localhost:42/user/alice/file')
  assert_false(s3fs.isfile.called)

  proxy_fs.open('/user/alice/file')
  hdfs.open.assert_called_once_with('/user/alice/file')
  assert_false(s3fs.open.called)

  assert_raises(IOError, proxy_fs.stats, 'ftp://host')
  assert_raises(IOError, proxy_fs.stats, 's3//bucket/key')
コード例 #4
0
def test_fs_selection():
    try:
        from mock import MagicMock
    except ImportError:
        raise SkipTest("Skips until HUE-2947 is resolved")

    s3fs, hdfs = MagicMock(), MagicMock()
    proxy_fs = ProxyFS({'s3a': s3fs, 'hdfs': hdfs}, 'hdfs')

    proxy_fs.isdir('s3a://bucket/key')
    s3fs.isdir.assert_called_once_with('s3a://bucket/key')
    assert_false(hdfs.isdir.called)

    proxy_fs.isfile('hdfs://localhost:42/user/alice/file')
    hdfs.isfile.assert_called_once_with('hdfs://localhost:42/user/alice/file')
    assert_false(s3fs.isfile.called)

    proxy_fs.open('/user/alice/file')
    hdfs.open.assert_called_once_with('/user/alice/file')
    assert_false(s3fs.open.called)

    assert_raises(IOError, proxy_fs.stats, 'ftp://host')
    assert_raises(IOError, proxy_fs.stats, 's3//bucket/key')