diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 17ef5b3..ea15a42 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 diff --git a/README.md b/README.md index 136d6cb..3e5cd1e 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 diff --git a/leancloud/utils.py b/leancloud/utils.py index f7d8ca0..14afb6a 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_file.py b/tests/test_file.py index 34b2b5c..76a6cbf 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 diff --git a/tests/test_query.py b/tests/test_query.py index 42e0d62..092d65f 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