Skip to content

Commit 693e8a7

Browse files
committed
Test search method
1 parent 27f98ec commit 693e8a7

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Changelog
66

77
- Use `pyproject.toml` instead of `setup.py` [tomgross]
88
- Document `eapi`-endpoint for fs.opener [tomgross]
9+
- Implement undocumented `search`-method (#93) [tomgross]
910

1011
1.4 (2024-12-29)
1112
----------------

README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ b) from data:
8181
>>> img.save(bio, format='jpeg')
8282
>>> pc.uploadfile(data=bio.getvalue(), filename="image.jpg", path='/path-to-pcloud-dir')
8383

84+
Searching files
85+
---------------
86+
87+
The pCloud-API allows searching files, even this is not documented in the official
88+
pCloud documentation.
89+
90+
>>> pcapi.search(query="foo", offset=20, limit=10)
91+
8492
PyFilesystem integration
8593
++++++++++++++++++++++++
8694

src/pcloud/tests/test_integration.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def pycloud():
1616
return PyCloud(username, password, endpoint="eapi")
1717

1818

19+
testfilename = "Getting started with pCloud.pdf"
1920
folder_for_tests = "integration-test"
2021
# upload `data/upload.txt` to integration test instance,
2122
# generate a public link (code) and insert the code below.
@@ -65,7 +66,6 @@ def test_publink_zip(pycloud):
6566

6667

6768
def test_copyfile(pycloud, testfolder):
68-
testfilename = "Getting started with pCloud.pdf"
6969
tofilename = f"/{folder_for_tests}/{testfilename}"
7070
resp = pycloud.copyfile(path=f"/{testfilename}", topath=tofilename)
7171
assert resp["result"] == 0
@@ -76,6 +76,10 @@ def test_copyfile(pycloud, testfolder):
7676
== "df745d42f69266c49141ea7270c45240cf883b9cdb6a14fffcdff33c04c5304c"
7777
), f"Failure with checksum in {resp}"
7878

79+
def test_search(pycloud):
80+
resp = pycloud.search(query=testfilename, limit=1)
81+
assert len(resp['items']) == 1
82+
assert resp['items'][0]['name'] == testfilename
7983

8084
def test_listtokens(pycloud):
8185
result = pycloud.listtokens()

0 commit comments

Comments
 (0)