code: def test_fsspec_adapter():
      """
      Assuming the implementations follows fsspec strictly, we only need to test if the adapter
      works correctly.
      """
      from ..fsspec_adapter import FsSpecAdapter
  
      adapter = FsSpecAdapter(scheme="memory")
  
      fs = adapter._fs
      # generate directories and files as follows:
      # .
      # ├── dir
      # │   ├── bar.txt
      # │   └── subdir
      # │       └── baz.txt
      # └── foo.txt
      with fs.open("foo.txt", mode="wb") as f:
          f.write(str.encode("foo"))
      fs.mkdir("dir")
      fs.mkdirs("/dir/subdir")
      with fs.open("/dir/bar.txt", mode="wb") as f:
          f.write(str.encode("bar"))
      with fs.open("/dir/subdir/baz.txt", mode="wb") as f:
          f.write(str.encode("baz"))
  
      # open
      f = adapter.open("test.txt", mode="wb")
      f.write(str.encode("test"))
      f.close()
  
      # cat
      assert "test" == adapter.cat("test.txt").decode()
      try:
          adapter.cat("non-existent.txt")
          pytest.fail()
      except FileNotFoundError:
          pass
  
      # ls
      entries = adapter.ls("/")
      assert 3 == len(entries)
      assert "/test.txt" in entries
      assert "/foo.txt" in entries
      assert "/dir" in entries
      entries = adapter.ls("dir")
      assert 2 == len(entries)
      assert "/dir/bar.txt" in entries
      assert "/dir/subdir" in entries
      entries = adapter.ls("test.txt")
      assert 1 == len(entries)
      assert "/test.txt" in entries
      try:
          adapter.ls("non-existent.txt")
          pytest.fail()
      except FileNotFoundError:
          pass
  
      # stat
      stat = adapter.stat("test.txt")
      assert stat is not None
      assert stat["name"] == "/test.txt"
      assert stat["type"] == "file"
      stat = adapter.stat("dir")
      assert stat is not None
      assert stat["name"] == "/dir"
      assert stat["type"] == "directory"
      try:
          adapter.stat("non-existent.txt")
          pytest.fail()
      except FileNotFoundError:
          pass
  
      # exists
      assert adapter.exists("test.txt")
      assert not adapter.exists("non-existent.txt")
  
      # isdir
      assert adapter.isdir("dir")
      assert not adapter.isdir("test.txt")
      assert not adapter.isdir("non-existent.txt")
  
      # isfile
      assert adapter.isfile("test.txt")
      assert not adapter.isfile("dir")
      assert not adapter.isfile("non-existent.txt")
  
      # glob
      # the expected results come from built-in glob lib.
      expected = [
          "foo.txt",
          "dir",
          "dir/subdir",
          "dir/subdir/baz.txt",
          "dir/bar.txt",
          "test.txt",
      ].sort()
      actual = adapter.glob("**", recursive=True).sort()
      assert actual == expected
      expected = ["foo.txt"]
      actual = adapter.glob("**/foo.txt", recursive=True)
      assert actual == expected
      expected = ["dir/bar.txt"]
      actual = adapter.glob("**/bar.txt", recursive=True)
      assert actual == expected
      expected = ["dir/subdir/baz.txt"]
      actual = adapter.glob("**/baz.txt", recursive=True)
      assert actual == expected
      expected = ["dir/bar.txt", "dir/subdir/baz.txt"]
      actual = adapter.glob("**/ba[rz].txt", recursive=True)
      assert actual == expected
      actual = adapter.glob("**/ba?.txt", recursive=True)
      assert actual == expected
      expected = ["foo.txt", "test.txt", "dir"].sort()
      actual = adapter.glob("**", recursive=False).sort()
      assert actual == expected
      actual = adapter.glob("*", recursive=False).sort()
      assert actual == expected
      expected = ["foo.txt", "test.txt"].sort()
      actual = adapter.glob("*.txt", recursive=False).sort()
      assert actual == expected
  
label_desc: Use image node_id 1 for calling a global function with example usage: test_fsspec_adapter() without return types