Commit graph

123 commits

Author SHA1 Message Date
Sagar Vora
61bc172d95 test: remove unused var 2026-01-23 14:45:23 +05:30
Alex Leach
8a82699640
fix(tests): Update more tests to conform with nh3 behaviour 2026-01-04 00:52:14 +00:00
Sagar Vora
2b9752097f
refactor!: deprecate older web view links (#35150) 2025-12-10 18:12:49 +05:30
P-Froggy
00a5fde3ad
feat: Enable _doc_before_save for child documents (#33279)
* Initial Commit

* Apply suggestion from @ankush

* refactor: move unrelated code out of try-except block

* test: child table level value change detection

---------

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
Co-authored-by: Ankush Menat <ankush@frappe.io>
2025-07-11 12:33:00 +00:00
Ankush Menat
44681433c9
fix: for_update for lazy loaded documents (#32897)
* fix: Support for_update on lazy documents

* fix: Pop for_update from arguments

* fix: Don't init empty child tables
2025-06-11 10:02:36 +00:00
Ankush Menat
899a2cfc49
test: Add test for update, set (#32895) 2025-06-11 09:05:44 +00:00
Ankush Menat
728aa3ccb8 test: ensure that lazy methods are in-sync 2025-06-11 10:26:13 +05:30
Ankush Menat
893a87df86 fix: append and extend without touching attributes 2025-06-11 10:07:48 +05:30
Ankush Menat
5c886ef091 test: test internal implementation of LazyChildTable 2025-06-11 09:55:45 +05:30
Ankush Menat
4d7348d3c0 refactor: avoid code duplication 2025-06-11 09:55:36 +05:30
Ankush Menat
3e4e944ae9 fix: dont db_update what hasn't changed 2025-06-11 09:55:01 +05:30
Ankush Menat
022dbf444d fix: make doc.save work and empty tables 2025-06-11 09:55:01 +05:30
Ankush Menat
eb77ddab69 feat: Lazy loaded documents
https://docs.python.org/3/howto/descriptor.html#invocation-from-an-instance

After first invokation, object's __dict__ will be used... then we can
assume rest of the code works as expected (?)
2025-06-11 09:55:01 +05:30
Ankush Menat
22827056ce fix: Assert type of link field values 2025-06-10 10:10:51 +05:30
Sagar Vora
fa252691b6 test: update status codes 2025-02-19 12:41:17 +05:30
Sagar Vora
f4062b4d7a fix: ensure consistent error in response 2025-02-19 12:10:59 +05:30
Akhil Narang
5a4239fbe3
chore(printview): change error message
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-12-23 13:29:44 +05:30
David Arnold
95950c8d81
refactor: organize test contextmanagers (#28041)
* refactor: prefer staticmethod decorator

* refactor: add cm register utility and keep cms in one file

* refactor: enter safe_exec enabled context (treewide)

* refactor: move trace fields to the other test context managers

* chore: marke all test_runner functions for deprecation

* chore: mark some tests.utils functions for deprecation (moved)

* chore: mark traced_field_conext for deprecation (moved)

* chore: placate semgrep in dumpster

* fix: show deprecation warnings per module in tests (incl. from dumpster)

* chore: remove use of deprecated functions from tests
2024-10-09 02:09:19 +02: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
Rutwik Hiwalkar
b1e6f691a7 test: add more tests for discard 2024-04-17 20:54:15 +05:30
Rutwik Hiwalkar
c341360e36 test: add test for discard action 2024-04-16 20:36:04 +05:30
Ankush Menat
1ec4d658fc fix: Allow setting UUID to application code 2024-03-29 19:02:28 +05:30
Ankush Menat
0fff2755d6
test: separate out risky tests (#25179) 2024-02-29 16:10:08 +00:00
Ankush Menat
0c9cc2e6ce test: NOWAIT functionality 2024-02-29 17:46:30 +05:30
Ankush Menat
0d847439b6 test: add more tests for has_value_changed 2024-02-19 10:42:21 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
Hussain Nagaria
b9fef7eb8d test: base class update on has web view update 2023-12-29 22:02:38 +05:30
Ankush Menat
4d68a46b10
fix: Set default child table fields on save (#23913)
We set defaults on creation of new doc but when you append a new child
doc on existing document it doesn't seem to set the defaults.

This seems like a bug and not a deliberate choice.
2023-12-22 08:02:36 +00:00
mergify[bot]
fdcfb82f47
Merge pull request #22114 from gavindsouza/doc-bulk_insert-include_child
fix: Handle child record insertions via bulk_insert
2023-08-25 13:57:38 +00:00
Gavin D'souza
c89130caf0
test: Add checks for child records bulk inserts
doc bulk_insert for "Role Profile" tables
2023-08-25 11:56:52 +05:30
Sagar Vora
91ceb889cc test: ensure only property can be called for virtual docfields 2023-08-18 23:04:22 +05:30
Ankush Menat
039be73af4
refactor: Consider singles for dynamic set_value usage (#21367)
Found all usage using this semgrep rule:

```yaml
    - pattern: frappe.db.set_value($DOCTYPE, ...)
    - pattern-not: frappe.db.set_value("$STR", ...)
```
2023-06-14 10:46:25 +05:30
Ankush Menat
4a81d9f8e3
feat!: populate fields from kwargs in frappe.new_doc (#21190)
This makes it similar to `get_doc` API BUT still signifies intent that
it's a "NEW" document.

Minor Breaking Change: positional arguments are now forcefully keyword
arguments. Only seems to be used internally from what I can tell.

https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/frappe/.*+/frappe.new_doc%5C%28.*%3F%2C.*%3F%5C%29/+lang:python+&patternType=regexp&case=yes&sm=0&groupBy=repo
2023-05-31 12:29:31 +05:30
Raffael Meyer
c7ef28fa0c
fix: don't validate to & from dates if any one is missing in validate_from_to_dates (#19079) 2022-12-03 18:32:59 +05:30
Ankush Menat
a6af1ed542 feat: bulk insert simple Document objects 2022-11-28 15:32:20 +05:30
Sagar Vora
a42ca7d8c1
fix: raise exception if doc before save is not found (#18796)
* fix: raise exception if doc before save is not found

* test: ensure error is raised when trying to save new doc using `doc.save()`

* chore: add comment explaining condition

* test: clearer name and docstring
2022-11-09 19:45:41 +05:30
Ankush Menat
061a9aa2ab test: db_set does not query for new doc
[skip ci]
2022-10-19 10:58:29 +05:30
Ankush Menat
b8ed8d624c fix: ignore child tables when init-ing parent doc 2022-10-04 14:27:25 +05:30
mergify[bot]
615b27b675
Merge pull request #17854 from netchampfaris/text-editor-has-content
fix: has_content check for fieldtype TextEditor
2022-08-17 11:57:36 +00:00
Ankush Menat
3e2d2a703a test: Use FrappeTestCase everywhere 2022-08-17 16:39:42 +05:30
Ankush Menat
41af9621cd test: undo custom field creation 2022-08-17 16:39:42 +05:30
Faris Ansari
10e49a19b8 test: Text Editor only image content 2022-08-17 15:45:11 +05:30
Ankush Menat
e7082d611f
fix: broken realtime doc change updates (#17567) 2022-07-20 21:05:23 +05:30
Ankush Menat
261fbfcd11
Revert "fix(doc)!: Always cast datetime, date and time fields"
Revert "fix(doc)!: Always cast datetime, date and time fields (#15891)"

This reverts commit d7789ab6ff.
2022-07-05 13:43:32 +05:30
Himanshu
d7789ab6ff
fix(doc)!: Always cast datetime, date and time fields (#15891)
### BREAKING CHANGE
#### Datetime, Date and Time fields will always be cast to respective objects in `setattr`, this will ensure uniformity while accessing the values, no more `getdate`, `get_datetime`, `to_timedelta` wrapper.
- While importing data, the framework does check for `set_only_once`.
- In normal case scenarios, this will work flawlessly since most date fields might not be set_only_once.
- But in Subscription, the date field is set to `set_only_once` and in `after_insert`, `document.save` is called, and while doing so, `set_only_once` is checked [here](1944a547f9/frappe/model/document.py (L566)).
-This works fine if the data imported is in the correct format.
- If the date's data is not in the correct format, the framework throws an error.
- for eg `06-02-2022 00:00:00 != 06-02-2022`
- fixes [Issue/#15370](https://github.com/frappe/frappe/issues/15370)

> no-docs
2022-07-05 07:07:16 +00:00
Ankush Menat
9a5d11234c
fix: validate scheduler, hook method names (#17400)
* chore: warn about missing scheduler / doc events

* fix: pass list instead of filter

filter can only be iterated upon once

* refactor: many typehints in __init__.py
2022-07-04 19:29:16 +05:30
Suraj Shetty
ff6a2e11d1 test: Update test case and add more assertions 2022-05-31 15:00:09 +05:30
Suraj Shetty
e740d72468 refactor: Use boolean while setting a flag 2022-05-30 16:29:46 +05:30
Suraj Shetty
1d9d395d76 test: Case to validate Web Link authentication 2022-05-30 15:35:47 +05:30
Sagar Vora
a33c2e2abe
refactor(BaseDocument)!: improved get, set and extend methods (#16540)
* perf!: 80% faster doc.get for fields with `None` as value

* perf: quicker init child (#3)

* refactor: avoid repitition and improve error message

* test: `doc.extend`

* fix: improve constant naming

* fix: minor improvements and tests

* refactor: improve naming
2022-05-04 18:37:06 +05:30