Commit graph

66 commits

Author SHA1 Message Date
Akhil Narang
26ae0f3460
fix: ruff fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-07 17:04:31 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
Ankush Menat
dedadbb0d9 perf: optional faster perm check for files 2024-01-31 10:49:18 +05:30
Shariq Ansari
f679f65aa5 test: unit test to check arabic filename export 2023-12-07 13:42:24 +05:30
Akhil Narang
eb45da3913
feat: Allow usage of print() within safe_exec() (#23084)
* feat(safe_exec): allow usage of `print()`

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

* refactor(system_console): update description to mention `print()` instead of `log()`

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

* feat: unconditionally add debug logs to response if present

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

* chore(safe_exec): add in a test for running `print()` within safe_exec

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

* fix(safe_exec): ignore warning

RestrictedPython warns us if we call `print()` don't use their `printed` variable

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

* feat: store debug logs from scheduled jobs

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

* fix: avoid ignoring warnings, disabled in prod anyway

* chore: remove unnecessary logging

This can be moved to level 2 when required

---------

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
Co-authored-by: Ankush Menat <ankush@frappe.io>
2023-11-20 12:45:41 +05:30
Ankush Menat
c4815ff987 fix!: Don't silently fail API auth 2023-11-01 17:51:23 +05:30
Ankush Menat
a46389a7e4 test: Split API v2 tests
Duplication here seems better than weird and hard to understand
parameterized version.
2023-10-17 10:27:37 +05:30
Ankush Menat
e2714c3e1c feat: v2 error and debug log structure 2023-10-16 18:13:50 +05:30
Ankush Menat
018ed845bd refactor: defer unnecessary json-dumping of messages
Also avoid accessing locals where interface is present like for popping last message.
2023-10-16 18:13:50 +05:30
Ankush Menat
411819ef81 feat: v2 for message response strucutre 2023-10-16 18:13:50 +05:30
Ankush Menat
3cc2ca8fc7 test: old API messages 2023-10-16 18:13:50 +05:30
Ankush Menat
dfcb69ab21 refactor: use reportview get_count implementation
Count reported should be according to permissions
2023-10-16 18:13:50 +05:30
Ankush Menat
47538f7601 feat: doctype collection level APIs - meta, count 2023-10-16 18:13:50 +05:30
Ankush Menat
cfd3fb9341 refactor: PUT == PATCH
Correct conventions for partial updates
2023-10-16 18:13:50 +05:30
Ankush Menat
c8cd658d26 fix: add login and logout methods 2023-10-16 18:13:50 +05:30
Ankush Menat
232f080044 feat: run_doc_method v2 2023-10-16 18:13:50 +05:30
Ankush Menat
e63f0c895d refactor: resource => document
This lets us create three types of APIs:

- Document APIs that operate on documents
- DocType APIs that operate on collections - list, count, search
- Method APIs that are RPC calls
2023-10-16 18:12:53 +05:30
Ankush Menat
0a244b10fc test: basic tests v2 API 2023-10-16 18:12:53 +05:30
Ankush Menat
947e7f6864 test: refactor API test cases for paramterization 2023-10-16 18:12:53 +05:30
Ankush Menat
627b777a9c refactor!: manual creation of response
This contains minor breaking change where `delete` API call now returns `OK` in `data` key instead of `message`.
2023-10-16 18:12:53 +05:30
Ankush Menat
0b0b7f7f60 test: check that document actually got deleted 2023-10-16 18:12:53 +05:30
Ankush Menat
909457de3d
fix: PDF and raw response (#22402) 2023-09-13 16:42:49 +00:00
Ankush Menat
970a740164
revert: #22308 (#22389)
* Revert "chore: move function to correct file"

This reverts commit ebfdfa283b.

* Revert "refactor!: merge get_site_url into get_url (#22308)"

This reverts commit 2001bc278f.
2023-09-13 14:34:52 +05:30
David Arnold
2001bc278f
refactor!: merge get_site_url into get_url (#22308)
* chore: merge get_site_url into get_url

* fix: keep alias with deprecation notice
2023-09-11 15:09:05 +05:30
Sagar Vora
b395a84d0b
fix!: remove version API (#21786) 2023-07-24 13:01:45 +05:30
Deepesh Garg
e38078a69f
test: Patch hooks for testing (#21702)
* test: Patch hooks for testing

* test: hooks patcher

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2023-07-17 12:41:27 +05:30
Gavin D'souza
55b31fcdfa test: Added test for before/after request hook 2023-02-10 13:22:27 +05:30
Ankush Menat
98dd7b0616
refactor: simplify api.py (#18372) 2022-10-12 15:18:39 +05:30
Ankush Menat
7f316fa427 test: add api tests for read only mode 2022-09-09 17:34:46 +05:30
Ankush Menat
3e2d2a703a test: Use FrappeTestCase everywhere 2022-08-17 16:39:42 +05:30
Gavin D'souza
7b149d4273 fix: Allow setting kwarg site for make_request test util 2022-08-05 13:54:58 +05:30
Ankush Menat
81b37cb7d2
refactor: clean up code to py310 supported features (#17367)
refactor: clean up code to py39+ supported syntax

- f-strings instead of format
- latest typing support instead of pre 3.9 TitleCase
- remove UTF-8 declarations.
- many more changes

Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
2022-07-01 11:51:05 +05:30
Suraj Shetty
c0c5b2ebdd
style: format all python files using black (#16453)
Co-authored-by: Frappe Bot <developers@frappe.io>
2022-04-12 10:59:25 +05:30
Suraj Shetty
80e8460850 test: Allow more options like content_type to be passed
`kwargs` is used internally while creating EnvironBuilder which eventually builds request object so additional options of request like content_type or mimetype  can be passed via kwargs
2022-04-04 07:14:43 +05:30
Gavin D'souza
6aec566325 test(test_api): Use login manager instead of request login
Also, move setUp for method into "correct" TestCase class
2022-02-24 11:34:29 +05:30
Gavin D'souza
19504d3908 test: Add tests for auth & run_method 2022-02-11 15:25:29 +05:30
Gavin D'souza
8b01c04a75 chore: Add type hints 2022-02-11 13:18:24 +05:30
Gavin D'souza
ced22e30f0 fix(test_api): Don't suppress debug query 2022-02-11 11:47:31 +05:30
Gavin D'souza
0a47cc0dcd fix(test): Make requests to the QSGI app in separate threads
Did this to mimic how requests are handled in dev/prod servers - new
thread for new request ;)
2022-02-11 00:36:29 +05:30
Gavin D'souza
b264d67b9f test(fix): Retain data apart from test_api tests
The tests in the TestResourceAPI Case destroy and re-build locals. This
may cause loss of data and make other tests flaky
2022-02-10 01:43:51 +05:30
Gavin D'souza
08279e30c9 fix: Use cls to specify class attrs and self for instance's 2022-02-10 01:31:08 +05:30
Gavin D'souza
7b4580d693 test(fix): Use FrappeAPITestCase for Method APIs case 2022-02-09 22:36:07 +05:30
Gavin D'souza
188373b1eb refactor(test): Frappe REST Test Suite
* Use Werkzeug Test Client instead of requests
    This change should start tracking coverage for the `api` module.
    Committing to ensure state maintainence will not be necessary.
* Refactor get_test_client to reset locals on each request
* Separate FrappeAPITestCase to enable formation of a generic API testing engine.
2022-02-09 17:02:40 +05:30
Suraj Shetty
d31572a799 test: Fix flaky API test 2021-06-24 18:49:21 +05:30
Gavin D'souza
e5db89dd4d fix: commit for postgres db_type before each TestAPI test 2021-06-14 13:44:20 +05:30
Gavin D'souza
3b310afc68 Revert "fix(test): Retry flaky test"
This reverts commit 7a30b2455e.
2021-06-14 13:43:52 +05:30
Gavin D'souza
7a30b2455e fix(test): Retry flaky test
test_update_document test randomly breaks in Postgres CI. The remedy right now is to re-run the builds until the success checks come up. This change retries the specific test 2 more times before failing the build
2021-06-09 13:09:24 +05:30
Gavin D'souza
dfc23eb3a3 fix(test): Set admin password correctly 2021-05-21 11:22:19 +05:30
Gavin D'souza
4a814571a8 test: Added tests for Frappe APIs
* Added tests for /api/resource usage
* Added tests for /api/method base endpoints
2021-05-20 19:26:11 +05:30
Gavin D'souza
98100437d0 chore: Renamed test files "appropriately" 2021-05-20 16:52:48 +05:30