예제 #1
0
def test_multi_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 = MagicMock(), MagicMock(), MagicMock(), MagicMock()
    proxy_fs = ProxyFS({'s3a': wrapper(s3fs), 'hdfs': wrapper(hdfs), 'adl': wrapper(adls), 'abfs': wrapper(abfs)}, 'hdfs')
    proxy_fs.setuser(user)

    proxy_fs.copy('s3a://bucket1/key', 's3a://bucket2/key')
    s3fs.copy.assert_called_once_with('s3a://bucket1/key', 's3a://bucket2/key')
    assert_false(hdfs.copy.called)

    proxy_fs.copyfile('s3a://bucket/key', 'key2')
    s3fs.copyfile.assert_called_once_with('s3a://bucket/key', 'key2')
    assert_false(hdfs.copyfile.called)

    proxy_fs.copyfile('adl://net/key', 'key2')
    adls.copyfile.assert_called_once_with('adl://net/key', 'key2')
    assert_false(hdfs.copyfile.called)

    proxy_fs.copyfile('abfs:/key', 'key2')
    abfs.copyfile.assert_called_once_with('abfs:/key', 'key2')
    assert_false(hdfs.copyfile.called)

    proxy_fs.rename('/tmp/file', 'shmile')
    hdfs.rename.assert_called_once_with('/tmp/file', 'shmile')
    assert_false(s3fs.rename.called)

    # Will be addressed in HUE-2934
    assert_raises(NotImplementedError, proxy_fs.copy_remote_dir, 's3a://bucket/key', 'adl://tmp/dir') # Exception can only be thrown if scheme is specified, else default to 1st scheme
예제 #2
0
def test_multi_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.copy('s3a://bucket1/key', 's3a://bucket2/key')
  s3fs.copy.assert_called_once_with('s3a://bucket1/key', 's3a://bucket2/key')
  assert_false(hdfs.copy.called)

  proxy_fs.copyfile('s3a://bucket/key', 'key2')
  s3fs.copyfile.assert_called_once_with('s3a://bucket/key', 'key2')
  assert_false(hdfs.copyfile.called)

  proxy_fs.rename('/tmp/file', 'shmile')
  hdfs.rename.assert_called_once_with('/tmp/file', 'shmile')
  assert_false(s3fs.rename.called)

  # Will be addressed in HUE-2934
  assert_raises(NotImplementedError, proxy_fs.copy_remote_dir, 's3a://bucket/key', '/tmp/dir')
예제 #3
0
def test_multi_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.copy('s3a://bucket1/key', 's3a://bucket2/key')
  s3fs.copy.assert_called_once_with('s3a://bucket1/key', 's3a://bucket2/key')
  assert_false(hdfs.copy.called)

  proxy_fs.copyfile('s3a://bucket/key', 'key2')
  s3fs.copyfile.assert_called_once_with('s3a://bucket/key', 'key2')
  assert_false(hdfs.copyfile.called)

  proxy_fs.rename('/tmp/file', 'shmile')
  hdfs.rename.assert_called_once_with('/tmp/file', 'shmile')
  assert_false(s3fs.rename.called)

  # Will be addressed in HUE-2934
  assert_raises(NotImplementedError, proxy_fs.copy_remote_dir, 's3a://bucket/key', '/tmp/dir')
예제 #4
0
def test_multi_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.copy('s3a://bucket1/key', 's3a://bucket2/key')
    s3fs.copy.assert_called_once_with('s3a://bucket1/key', 's3a://bucket2/key')
    assert_false(hdfs.copy.called)

    proxy_fs.copyfile('s3a://bucket/key', 'key2')
    s3fs.copyfile.assert_called_once_with('s3a://bucket/key', 'key2')
    assert_false(hdfs.copyfile.called)

    proxy_fs.rename('/tmp/file', 'shmile')
    hdfs.rename.assert_called_once_with('/tmp/file', 'shmile')
    assert_false(s3fs.rename.called)

    # Will be addressed in HUE-2934
    assert_raises(NotImplementedError, proxy_fs.copy_remote_dir,
                  's3a://bucket/key', '/tmp/dir')