Commit graph

34 commits

Author SHA1 Message Date
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
Rushabh Mehta
6445b08b7c fix(test): remove test for /search 2024-09-25 16:03:46 +05:30
barredterra
3561f502d1 test: search relevance 2024-03-27 00:40:21 +01:00
Ankush Menat
fbaa2549f2 test: add test for searching with paren 2024-03-20 12:30:11 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
Ankush Menat
3effd9e101 test: fix test failure from parallel merge 2023-10-16 16:42:46 +05:30
Ankush Menat
c476c5e6d7
refactor!: Link field search (#22745)
* refactor!: Drop handling for SQL queries

This hasn't been supported in really long time, no need to check that
use cases.

It will still fail but with no special error message.

* fix: Catch all import related errors

* fix!: Use last query from hooks

* refactor!: Return search results like any other function

Search results are returned in `results` key which is incosistent from
most other functions

* refactor: simplify search_link
2023-10-16 15:41:02 +05:30
Corentin Flr
89aab5d748
fix(query_doctypes): Allow search in translated name (#22590)
* fix(query_doctypes): Allow search in translated name

* test: Add test for DocType search in foreign language
2023-10-16 15:13:57 +05:30
Ankush Menat
55a444959e fix: Make search_link query postgres compatible 2023-10-16 11:51:51 +05:30
Ankush Menat
fec7759d00 fix: Give idx higher preference than meta order
Meta order in most cases is default "modified" which doesn't quite help.

idx is # of times a document is referred to somewhere else, which is
more likely to be relevant.
2023-10-16 10:50:57 +05:30
Ankush Menat
31444228c3 fix: Improve search relevance for search_link
When `locate` returns 0 it's shown on top instead it should be shown
last or not shown at all.

This is math hack to avoid using any complex SQL functionality which
isn't allowed in DB query.
2023-10-16 10:46:47 +05:30
Ankush Menat
109a549a23
fix: pass reference_doctype to search query methods (#20842)
frappe.call ensures that it's only passed to functions which can accept
it, so nothing to worry about ~ backward compatible change.
2023-04-25 18:31:14 +05:30
Gavin D'souza
471290bd92 test: Make test_link_field_order re-runable 2023-02-06 12:39:44 +05:30
Gavin D'souza
d357af1533 refactor: Add a maxsplit limit to string splits 2023-01-24 19:22:51 +05:30
Sagar Vora
6fe9f9b411
test: remove duplication in test_search 2022-12-16 10:21:50 +05:30
Daizy Modi
9a8dbc42a7 fix: added a case with backticks 2022-12-14 17:01:19 +05:30
Daizy Modi
3e824a9ea5 test: test case for sanitize_searchfield 2022-12-14 16:47:23 +05:30
Ankush Menat
3ddac5fe92
refactor: accurate translation caching (#18595)
* refactor: rename poorly named functions

* refactor: getting translation from apps

- use generator
- use sane name for cache key
- avoid manual handling of frappe.local state just use cache() interface
2022-10-27 16:28:02 +05:30
mergify[bot]
209a00d60a
fix: correct import for markupsafe.escape (#18401)
ref: https://github.com/pallets/jinja/issues/1626
(cherry picked from commit c2f1c5744b269758ebce48b5fb8feac0488442c1)

[skip ci]

Co-authored-by: Ankush Menat <ankush@frappe.io>
2022-10-13 11:43:09 +05:30
Ankush Menat
d711c1fb7e
test: use FrappeTestCase for cleaning up state (#17768) 2022-08-09 16:26:40 +05:30
Ankush Menat
d90d6536ef perf: dont rebuild same translation dict 2022-05-22 22:54:23 +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
Karthikeyan Singaravelan
880832671a fix: use assertEqual instead of assertEquals for Python 3.11 compatibility 2022-03-21 11:05:43 +00:00
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
Mohammad Hasnain Mohsin Rajan
7ab7da5c65
fix: only enabled users in mentions (#14017)
* fix: only enabled users in mentions

* Update frappe/desk/search.py

Co-authored-by: gavin <gavin18d@gmail.com>

* test: add test cases to disallow disabled in mention

* test: pass roles as single values

* style: Remove extra space and line

Co-authored-by: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com>
Co-authored-by: gavin <gavin18d@gmail.com>
2021-08-27 05:09:40 +00:00
Gavin D'souza
6f17e3d45f perf(test_search): Setup and teardown tests only if needed 2021-07-14 12:02:33 +05:30
codescientist703
b619c3d330 test: added test for order of link 2021-07-13 20:24:24 +05:30
Gavin D'souza
e407b78506 chore: Drop dead and deprecated code
* Remove six for PY2 compatability since our dependencies are not, PY2
  is legacy.
* Removed usages of utils from future/past libraries since they are
  deprecated. This includes 'from __future__ ...' and 'from past...'
  statements.
* Removed compatibility imports for PY2, switched from six imports to
  standard library imports.
* Removed utils code blocks that handle operations depending on PY2/3
  versions.
* Removed 'from __future__ ...' lines from templates/code generators
* Used PY3 syntaxes in place of PY2 compatible blocks. eg: metaclass
2021-05-26 15:31:29 +05:30
Rushabh Mehta
864956e30f fix(minor): homepage for frappe and tests 2021-01-01 18:03:06 +05:30
Suraj Shetty
3368d83238
fix: Remove @ from relevance query (#11837) 2020-11-02 13:07:09 +05:30
Suraj Shetty
cd1ab8e23c
feat: Add validate_and_sanitize_search_inputs decorator (#11194)
* feat: Add validate_and_sanitize_search_inputs decorator

Co-authored-by: Nabin Hait <nabinhait@gmail.com>
Co-authored-by: Prssanna Desai <prssud@gmail.com>
Co-authored-by: Shivam Mishra <scmmishra@users.noreply.github.com>

* refactor: Move validate_and_sanitize_search_inputs to init

* refactor: Move validate_and_sanitize_search_inputs to search.py

* test: validate_and_sanitize_search_inputs decorator

* chore: Add wrapt module

* refactor: Use @wrapt to define validate_and_sanitize_search_inputs decorator

* test: Add a case to make sure frappe.call works as well

Co-authored-by: Nabin Hait <nabinhait@gmail.com>
Co-authored-by: Prssanna Desai <prssud@gmail.com>
Co-authored-by: Shivam Mishra <scmmishra@users.noreply.github.com>
2020-08-05 19:41:41 +05:30
Charles-Henri Decultot
dab491e55f Doctype links in foreign language (#5745)
* Doctype search in foreign language

* List comprehension slightly faster

* Remove obsolete comment

* Remove trailing whitespace

* Test case for address and contact query

* Refactor search and add tests

* Travis test debug

* Remove debug print

* Search limit removal for untranslated docs and tests refactor

* Remove old comments

* Test modification for Travis

* remove unused import

* Correct Role doctype
2018-08-24 15:23:20 +05:30
Saurabh
081b17fbe8 [security][fix] tighten criteria to prevent sql injection in search-f… (#5800)
* [security][fix] tighten criteria to prevent sql injection in search-fields

* test cases
2018-07-11 11:04:51 +05:30
Saurabh
e9cdf322c6 [security][fix] Sanitize search fields to avoid sql injection (#5713)
* [security][fix] Sanitize search fields to avoid sql injection

* Test Cases for Sanitizer

* Test Cases fix

* [fix] test case
2018-06-25 11:23:32 +05:30