Merge pull request #32865 from ankush/check_link_value
fix: Assert type of link field values
This commit is contained in:
commit
49a11a0112
5 changed files with 11 additions and 5 deletions
1
.github/workflows/_base-server-tests.yml
vendored
1
.github/workflows/_base-server-tests.yml
vendored
|
|
@ -55,7 +55,6 @@ jobs:
|
|||
timeout-minutes: 30
|
||||
env:
|
||||
NODE_ENV: "production"
|
||||
PYTHONOPTIMIZE: 2
|
||||
# noisy 3rd party library warnings
|
||||
PYTHONWARNINGS: "module,ignore:::babel.messages.extract"
|
||||
DB_ROOT_PASSWORD: db_root
|
||||
|
|
|
|||
5
.github/workflows/_base-ui-tests.yml
vendored
5
.github/workflows/_base-ui-tests.yml
vendored
|
|
@ -44,7 +44,6 @@ jobs:
|
|||
timeout-minutes: 30
|
||||
env:
|
||||
NODE_ENV: "production"
|
||||
PYTHONOPTIMIZE: 2
|
||||
# noisy 3rd party library warnings
|
||||
PYTHONWARNINGS: "ignore"
|
||||
DB_ROOT_PASSWORD: db_root
|
||||
|
|
@ -92,7 +91,7 @@ jobs:
|
|||
-x '${{ github.event.repository.name }}/public/dist/**' \
|
||||
-x '${{ github.event.repository.name }}/public/js/lib/**' \
|
||||
-x '**/*.bundle.js' --compact=false --in-place ${{ github.event.repository.name }}
|
||||
|
||||
|
||||
- name: Site Setup
|
||||
run: |
|
||||
source ${GITHUB_WORKSPACE}/env/bin/activate
|
||||
|
|
@ -102,7 +101,7 @@ jobs:
|
|||
- uses: browser-actions/setup-chrome@latest
|
||||
- run: |
|
||||
echo "BROWSER_PATH=$(which chrome)" >> $GITHUB_ENV
|
||||
|
||||
|
||||
- name: Run Tests
|
||||
run: |
|
||||
source ${GITHUB_WORKSPACE}/env/bin/activate
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ class TestRQJob(IntegrationTestCase):
|
|||
# If this starts failing analyze memory usage using memray or some equivalent tool to find
|
||||
# offending imports/function calls.
|
||||
# Refer this PR: https://github.com/frappe/frappe/pull/21467
|
||||
LAST_MEASURED_USAGE = 42
|
||||
LAST_MEASURED_USAGE = 46
|
||||
if frappe.conf.use_mysqlclient:
|
||||
# TEMP: Add extra allowance for running two connectors, this should be rolled back before v16
|
||||
LAST_MEASURED_USAGE += 2
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ from frappe.model.dynamic_links import invalidate_distinct_link_doctypes
|
|||
from frappe.model.naming import set_new_name
|
||||
from frappe.model.utils.link_count import notify_link_count
|
||||
from frappe.modules import load_doctype_module
|
||||
from frappe.types.docref import DocRef
|
||||
from frappe.utils import (
|
||||
cached_property,
|
||||
cast_fieldtype,
|
||||
|
|
@ -864,6 +865,10 @@ class BaseDocument:
|
|||
if not docname:
|
||||
continue
|
||||
|
||||
assert isinstance(docname, str | int | DocRef) or (
|
||||
isinstance(docname, list | tuple | set) and len(docname) == 1
|
||||
), f"Unexpected value for field {df.fieldname}: {docname}"
|
||||
|
||||
if df.fieldtype == "Link":
|
||||
doctype = df.options
|
||||
if not doctype:
|
||||
|
|
|
|||
|
|
@ -207,6 +207,9 @@ class TestDocument(IntegrationTestCase):
|
|||
|
||||
self.assertEqual(frappe.db.get_value("User", d.name), d.name)
|
||||
|
||||
d.append("roles", {"role": ("Guest", "Administrator")})
|
||||
self.assertRaises(AssertionError, d._validate_links)
|
||||
|
||||
def test_validate(self):
|
||||
d = self.test_insert()
|
||||
d.starts_on = "2014-01-01"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue