Commit graph

84 commits

Author SHA1 Message Date
Akhil Narang
90a40dbfe0
fix: ruff manual fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-12-22 21:06:48 +05:30
sokumon
dd2dc053ca chore: more renames to /desk 2025-12-18 20:45:04 +05:30
Sagar Vora
e3702efd44 refactor: move whitelist_for_tests to common utils and apply to all test endpoints
- Moved whitelist_for_tests decorator from ui_test_helpers to frappe.tests.utils
- Enhanced decorator to accept kwargs for passing to frappe.whitelist()
- Applied decorator consistently to test endpoints in:
  - test_api.py
  - test_api_v2.py
  - test_caching.py
  - test_search.py
- Updated all imports to use direct import from frappe.tests.utils
2025-11-21 16:38:11 +05:30
Akhil Narang
30d6ebc6c6
fix: tests
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-11-19 21:15:58 +05:30
sokumon
526ae1608f fix: server test 2025-11-14 23:05:13 +05:30
Akhil Narang
6dfcc2bf4c
Merge pull request #34027 from sumitbhanushali/expand-link
feat: add support of expand in rest api v1/document_list
2025-10-28 17:02:14 +05:30
Sumit Bhanushali
4cfc0c6b55 test: added rest api test user to avoid past user creation inconsistency 2025-10-22 12:12:36 +05:30
Akhil Narang
fad80b892e
fix: reset list outside loop
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-10-17 16:59:09 +05:30
Sumit Bhanushali
ed13cf2527 test: added test for expand getdoc and getlist 2025-10-16 18:00:27 +05:30
Akhil Narang
6ca4d4d167
refactor(treewide): ruff format
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-09-26 13:16:43 +05:30
Ayush Chaudhari
9f3e327231 test: better redirect handling 2025-09-17 21:42:25 +05:30
Ankush Menat
2dfb96f91c
fix: handle snapshot isolation errors better (#32318)
* fix: Avoid Snapshot violation

- Main thread created and "read" user
- Other thread modified something
- Main thread wants to delete or "write" to same row.

This violates snapshot isolation.

* fix: treat snapshot violation as deadlock for now

* test: handle snapshot violations
2025-04-28 06:18:38 +00:00
David Arnold
c114e5fae8
refactor: unit vs integration treewide (#27992)
* refactor: constitute unit test case

* fix: docs and type hints

* refactor: mark presumed integration test cases explicitly

At time of writing, we now have at least two base test classes:

- frappe.tests.UnitTestCase
- frappe.tests.IntegrationTestCase

They load in their perspective priority queue during execution.

Probably more to come for more efficient queing and scheduling.

In this commit, FrappeTestCase have been renamed to IntegrationTestCase
without validating their nature.

* feat: Move test-related functions from test_runner.py to tests/utils.py

* refactor: add bare UnitTestCase to all doctype tests

This should teach LLMs in their next pass that the distinction matters
and that this is widely used framework practice
2024-10-06 09:43:36 +00:00
Ankush Menat
65b3c42635
fix: only redirect to same domain (#26304)
This limits post login redirects to same domain to avoid social engineering attempts.
2024-05-02 18:02:18 +05:30
Ankush Menat
caf7aec286
feat(APIv2): Add comment via REST API (#25889)
```
POST /document/Sales Order/S0-123/add_comment
{
    text: "Comment"
}
```
2024-04-10 10:53:22 +00:00
Ankush Menat
13c74ec231 fix: Use debug log to log DB queries 2024-03-10 12:49:19 +05:30
Ankush Menat
bb7c3c289c
feat: support array request type (#25109)
There can be external APIs like webhooks that only send array request,
in which case Frappe has no mechanism to accept such requests.

After this PR such request data can be accessed using `data` list
argument on function.

I've considered directly storing list in form_dict but it's not
feasible:
1. It breaks semantics, "form_dict" can't be a list. That ship has long
   sailed.
2. Way too much code expects form_dict to be a dict.
2024-02-27 16:41:33 +00:00
Akhil Narang
3f1e19de85
refactor(treewide): enable RUF rules
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-21 16:20:28 +05:30
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