Repository: Tinche/aiofiles (language: python)

Issue:
Add aiofiles.os.readlink function
Following up on the symlink PR #124 this PR adds the `aiofiles.os.readlink` function to retrieve the symlinked path from the symlink.

Docs: https://docs.python.org/3/library/os.html#os.readlink

Added a test case.


Discussion / hints:
# [Codecov](https://codecov.io/gh/Tinche/aiofiles/pull/125?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tin+Tvrtkovi%C4%87) Report
> Merging [#125](https://codecov.io/gh/Tinche/aiofiles/pull/125?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tin+Tvrtkovi%C4%87) (d609474) into [master](https://codecov.io/gh/Tinche/aiofiles/commit/313f4a5116c03a60ee0b14d38c7b1782f6b60970?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tin+Tvrtkovi%C4%87) (313f4a5) will **increase** coverage by `0.03%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/Tinche/aiofiles/pull/125/graphs/tree.svg?width=650&height=150&src=pr&token=nUnoVWaIfu&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tin+Tvrtkovi%C4%87)](https://codecov.io/gh/Tinche/aiofiles/pull/125?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tin+Tvrtkovi%C4%87)

```diff
@@            Coverage Diff             @@
##           master     #125      +/-   ##
==========================================
+ Coverage   89.73%   89.76%   +0.03%     
==========================================
  Files          10       10              
  Lines         302      303       +1     
==========================================
+ Hits          271      272       +1     
  Misses         31       31              
```


| [Impacted Files](https://codecov.io/gh/Tinche/aiofiles/pull/125?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tin+Tvrtkovi%C4%87) | Coverage Δ | |
|---|---|---|
| [src/aiofiles/os.py](https://codecov.io/gh/Tinche/aiofiles/pull/125/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tin+Tvrtkovi%C4%87#diff-c3JjL2Fpb2ZpbGVzL29zLnB5) | `100.00% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Tinche/aiofiles/pull/125?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tin+Tvrtkovi%C4%87).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tin+Tvrtkovi%C4%87)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Tinche/aiofiles/pull/125?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tin+Tvrtkovi%C4%87). Last update [313f4a5...d609474](https://codecov.io/gh/Tinche/aiofiles/pull/125?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tin+Tvrtkovi%C4%87). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tin+Tvrtkovi%C4%87).


Fix patch:
diff --git a/README.rst b/README.rst
index be1d1a1..289b891 100644
--- a/README.rst
+++ b/README.rst
@@ -102,15 +102,21 @@ several useful ``os`` functions that deal with files:
 * ``stat``
 * ``sendfile``
 * ``rename``
+* ``renames``
 * ``replace``
 * ``remove``
+* ``unlink``
 * ``mkdir``
 * ``makedirs``
 * ``rmdir``
 * ``removedirs``
+* ``link``
+* ``symlink``
+* ``readlink``
 * ``path.exists``
 * ``path.isfile``
 * ``path.isdir``
+* ``path.islink``
 * ``path.getsize``
 * ``path.getatime``
 * ``path.getctime``
@@ -165,6 +171,21 @@ as desired. The return type also needs to be registered with the
 
 History
 ~~~~~~~
+0.9.0 (TBC)
+``````````````````
+* Added ``aiofiles.os.path.islink``.
+  `#126 <https://github.com/Tinche/aiofiles/pull/126>`_
+* Added ``aiofiles.os.readlink``.
+  `#125 <https://github.com/Tinche/aiofiles/pull/125>`_
+* Added ``aiofiles.os.symlink``.
+  `#124 <https://github.com/Tinche/aiofiles/pull/124>`_
+* Added ``aiofiles.os.unlink``.
+  `#123 <https://github.com/Tinche/aiofiles/pull/123>`_
+* Added ``aiofiles.os.link``.
+  `#121 <https://github.com/Tinche/aiofiles/pull/121>`_
+* Added ``aiofiles.os.renames``.
+  `#120 <https://github.com/Tinche/aiofiles/pull/120>`_
+
 0.8.0 (2021-11-27)
 ``````````````````
 * aiofiles is now tested on Python 3.10.
diff --git a/src/aiofiles/ospath.py b/src/aiofiles/ospath.py
index 8bb460a..a0a60f7 100644
--- a/src/aiofiles/ospath.py
+++ b/src/aiofiles/ospath.py
@@ -6,6 +6,7 @@
 exists = wrap(path.exists)
 isfile = wrap(path.isfile)
 isdir = wrap(path.isdir)
+islink = wrap(path.islink)
 getsize = wrap(path.getsize)
 getmtime = wrap(path.getmtime)
 getatime = wrap(path.getatime)


Test patch:
diff --git a/tests/test_os.py b/tests/test_os.py
index d496b41..25682a9 100644
--- a/tests/test_os.py
+++ b/tests/test_os.py
@@ -192,6 +192,16 @@ async def test_isdir():
     assert result
 
 
+@pytest.mark.asyncio
+async def test_islink():
+    """Test the path.islink call."""
+    src_filename = join(dirname(__file__), "resources", "test_file1.txt")
+    dst_filename = join(dirname(__file__), "resources", "test_file2.txt")
+    await aiofiles.os.symlink(src_filename, dst_filename)
+    assert await aiofiles.os.path.islink(dst_filename)
+    await aiofiles.os.remove(dst_filename)
+
+
 @pytest.mark.asyncio
 async def test_getsize():
     """Test path.getsize call."""