From 4809841321634ae8787a90e23e543f17cf2f3b80 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Tue, 7 Dec 2021 19:52:08 +0800 Subject: [PATCH 1/4] fix: missing url attribute when decoding file object MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thank 沉寂 for bringing this to our attention. --- leancloud/utils.py | 1 + tests/test_query.py | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/leancloud/utils.py b/leancloud/utils.py index f7d8ca07..14afb6a7 100644 --- a/leancloud/utils.py +++ b/leancloud/utils.py @@ -140,6 +140,7 @@ def decode(key, value): if meta_data: f._metadata = meta_data f._url = value["url"] + f._successful_url = value["url"] f.id = value["objectId"] return f diff --git a/tests/test_query.py b/tests/test_query.py index 42e0d62a..092d65f7 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -17,6 +17,7 @@ from leancloud import Query from leancloud import Object from leancloud import GeoPoint +from leancloud.file_ import File __author__ = "asaka " @@ -68,6 +69,9 @@ def setup_func(): game_score.set("playerName", "张三") game_score.set("location", GeoPoint(latitude=i, longitude=-i)) game_score.set("random", random.randrange(100)) + f = File("Blah.txt", open("tests/sample_text.txt", "rb")) + f.save() + game_score.set("attachment", f) game_score.save() return setup_func @@ -468,6 +472,12 @@ def test_include(): # type: () -> None result = Query(GameScore).include(["score"]).find() assert len(result) == 10 +@with_setup(make_setup_func()) +def test_attachment(): # type: () -> None + result = Query(GameScore).first() + print(result.dump()) + attachment = result.get('attachment') + assert attachment.url @with_setup(make_setup_func()) def test_select(): # type: () -> None From 1e477c6fe487d4adfe6c64369b0f655d7e841c07 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Tue, 7 Dec 2021 21:12:23 +0800 Subject: [PATCH 2/4] test: be nice with gluttony file buckets --- tests/test_file.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_file.py b/tests/test_file.py index 34b2b5c1..76a6cbfd 100644 --- a/tests/test_file.py +++ b/tests/test_file.py @@ -123,6 +123,9 @@ def test_save_with_specified_key(): # type: () -> None path = urlparse(f.url).path if path.startswith("/avos-cloud-"): # old school aws s3 file url assert path.split("/")[2] == user_specified_key + elif f.url.startswith("https://lc-gluttony"): # new aws s3 gluttony bucket + gluttony_path = "/" + os.environ["APP_ID"][0:12] + "/" + user_specified_key + assert path == gluttony_path else: assert path == "/" + user_specified_key From 83b91fb9f407e8522b890a0fc7e0ec28e9dc1e3f Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Tue, 7 Dec 2021 21:12:52 +0800 Subject: [PATCH 3/4] docs: test application configurations --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 136d6cbd..3e5cd1e1 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,22 @@ Configure the following environment variables: - `MASTER_KEY` - `USE_REGION` +Make sure the following options are configured on the LeanCloud console: + +- Data Storage > Settings > Include ACL with objects being queried: **checked** +- Push Notification > Push notification settings > Prevent clients from sending push notifications: **unchecked** +- Settings > Security > Service switches > Push notifications: **enabled** +- Settings > Security > Service switches > SMS: **disabled** + +And there is a cloud function naming `add` which returns `3` for `add(a=1, b=2)` deployed on the LeanEngine production environment of the application. +For example: + +```js +AV.Cloud.define('add', async function (request) { + return request.params["a"] + request.params["b"] +}) +``` + Install dependencies: ```sh From 9f10f07540d9e28af47ace8892589b4ce407eb48 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Tue, 7 Dec 2021 21:19:52 +0800 Subject: [PATCH 4/4] build: use new test application & hide app keys --- .github/workflows/pythonpackage.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 17ef5b37..ea15a429 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -57,9 +57,9 @@ jobs: pip install -e .'[test]' - name: Run tests with ${{ matrix.python-version }} env: - APP_ID: 8FfQwpvihLHK4htqmtEvkNrv - APP_KEY: eE9tNOcCiWoMHM1phxY41rAz - MASTER_KEY: 75zAjEJSj7lifKQqKSTryae9 + APP_ID: YJRGphy60b8JCBib0vtDDtak-MdYXbMMI + APP_KEY: ${{ secrets.APP_KEY }} + MASTER_KEY: ${{ secrets.MASTER_KEY }} USE_REGION: US run: nosetests -v