Commit graph

106 commits

Author SHA1 Message Date
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
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
Sagar Vora
4bb5ea609c
fix: get currency name from DB only if options are set and value is truthy (#16382)
* fix: call `frappe.db.exists` only if `options` are set and value is truthy

* fix: sider issue

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>

* fix: use `get_value` instead of `exists`

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>

* test: ensure currency formatting works without currency set in df options or param

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
2022-03-23 19:28:01 +05:30
Karthikeyan Singaravelan
880832671a fix: use assertEqual instead of assertEquals for Python 3.11 compatibility 2022-03-21 11:05:43 +00:00
Sagar Vora
c6049d7e7c
fix: always execute method if found in __dict__ (#15958)
285823
2022-02-28 12:42:08 +00:00
mergify[bot]
1df33cbfcf
Merge pull request #15975 from resilient-tech/fix-limit-without-filter
fix: limit without filter
2022-02-15 13:40:56 +00:00
Pruthvi Patel
7ce9f1eaa1 fix: limit without filter 2022-02-15 13:06:55 +05:30
Gavin D'souza
a403934265 test(fix): Generate Note to ensure at least one exists
ref: Failing Postgres CI on https://github.com/frappe/frappe/runs/5186523978?check_suite_focus=true
2022-02-15 12:03:26 +05:30
Gavin D'souza
8165cd2802 test: Add test for docfield.options virtual df usage 2022-02-01 19:00:10 +05:30
Gavin D'souza
9ca768a32c fix(test): Update test_virtual_fields 2022-01-28 12:12:30 +05:30
Gavin D'souza
57f89c8b05 test: Add test for dynamic docfield 2022-01-13 12:23:50 +05:30
Pruthvi Patel
a87899c215 test: add test for limit 2022-01-11 11:12:53 +05:30
Gavin D'souza
4b9d8c0258 fix: Remove extra Document.validate_owner validation 2022-01-04 15:31:08 +05:30
shadrak gurupnor
6c6ff2c16d fix: overriding of owner of doc
feat: Fixed the dilemma of owner field in ToDo document
2022-01-04 13:39:16 +05:30
Ankush Menat
abebd29ef4 test: fix expected failing test 2021-11-18 17:16:20 +05:30
Gavin D'souza
3446026555 chore: Update header: license.txt => LICENSE
The license.txt file has been replaced with LICENSE for quite a while
now. INAL but it didn't seem accurate to say "hey, checkout license.txt
although there's no such file". Apart from this, there were
inconsistencies in the headers altogether...this change brings
consistency.
2021-09-03 12:02:59 +05:30
Suraj Shetty
81cada8b6e
Merge branch 'develop' into get-frmt 2021-08-04 14:20:21 +05:30
Kenneth Sequeira
13caf6910a fix: test_document test fix 2021-06-15 22:33:06 +05:30