From 2b80e710bc7f982b6a0d30cd6d296bba089766ac Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Sat, 22 Aug 2020 21:15:45 +0530 Subject: [PATCH 1/3] fix(minor): client.get_value fix for single --- frappe/client.py | 7 ++++++- frappe/tests/test_api.py | 5 +++++ requirements.txt | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/frappe/client.py b/frappe/client.py index 6f19e78183..158a143ad0 100644 --- a/frappe/client.py +++ b/frappe/client.py @@ -87,7 +87,12 @@ def get_value(doctype, fieldname, filters=None, as_dict=True, debug=False, paren if not filters: filters = None - value = frappe.get_list(doctype, filters=filters, fields=fields, debug=debug, limit=1) + + if frappe.get_meta(doctype).issingle: + value = frappe.db.get_values_from_single(fields, None, doctype, as_dict=as_dict, debug=debug) + else: + value = frappe.get_list(doctype, filters=filters, fields=fields, debug=debug, limit=1) + if as_dict: value = value[0] if value else {} else: diff --git a/frappe/tests/test_api.py b/frappe/tests/test_api.py index 3139237cc9..45107612cc 100644 --- a/frappe/tests/test_api.py +++ b/frappe/tests/test_api.py @@ -74,6 +74,11 @@ class TestAPI(unittest.TestCase): self.assertRaises(FrappeException, server.get_value, "Note", "(select (password) from(__Auth) order by name desc limit 1)", {"title": "get_value"}) + def test_get_single(self): + server = FrappeClient(get_url(), "Administrator", "admin", verify=False) + server.set_value('Website Settings', 'Website Settings', 'title_prefix', 'test-prefix') + self.assertEqual(server.get_value('Website Settings', 'title_prefix').get('title_prefix'), 'test-prefix') + frappe.db.set_value('Website Settings', None, 'title_prefix', '') def test_update_doc(self): server = FrappeClient(get_url(), "Administrator", "admin", verify=False) diff --git a/requirements.txt b/requirements.txt index a88d0e3c1d..af3104cce7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -34,7 +34,7 @@ oauthlib==3.1.0 openpyxl==2.6.4 passlib==1.7.2 pdfkit==0.6.1 -Pillow==6.2.2 +Pillow==7.1.0 premailer==3.6.1 psycopg2-binary==2.8.4 pyasn1==0.4.8 From 7895ddf8654094dc9f8ea157beb651696c116d1e Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Sat, 22 Aug 2020 21:18:38 +0530 Subject: [PATCH 2/3] fix(minor): client.get_value fix for single --- frappe/client.py | 2 +- frappe/tests/test_api.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/frappe/client.py b/frappe/client.py index 158a143ad0..0db18421ef 100644 --- a/frappe/client.py +++ b/frappe/client.py @@ -89,7 +89,7 @@ def get_value(doctype, fieldname, filters=None, as_dict=True, debug=False, paren if frappe.get_meta(doctype).issingle: - value = frappe.db.get_values_from_single(fields, None, doctype, as_dict=as_dict, debug=debug) + value = frappe.db.get_values_from_single(fields, filters, doctype, as_dict=as_dict, debug=debug) else: value = frappe.get_list(doctype, filters=filters, fields=fields, debug=debug, limit=1) diff --git a/frappe/tests/test_api.py b/frappe/tests/test_api.py index 45107612cc..01ad11dde3 100644 --- a/frappe/tests/test_api.py +++ b/frappe/tests/test_api.py @@ -77,6 +77,7 @@ class TestAPI(unittest.TestCase): def test_get_single(self): server = FrappeClient(get_url(), "Administrator", "admin", verify=False) server.set_value('Website Settings', 'Website Settings', 'title_prefix', 'test-prefix') + self.assertEqual(server.get_value('Website Settings', 'title_prefix', 'Website Settings').get('title_prefix'), 'test-prefix') self.assertEqual(server.get_value('Website Settings', 'title_prefix').get('title_prefix'), 'test-prefix') frappe.db.set_value('Website Settings', None, 'title_prefix', '') From 07f5484ef29bca0e72987316edd94ef4de41b3e4 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Sun, 23 Aug 2020 13:19:38 +0530 Subject: [PATCH 3/3] fix(test): attempt to fix recorder test --- cypress/integration/recorder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/integration/recorder.js b/cypress/integration/recorder.js index 878d8af848..ed2a9c86ba 100644 --- a/cypress/integration/recorder.js +++ b/cypress/integration/recorder.js @@ -61,7 +61,7 @@ context('Recorder', () => { cy.visit('/desk#recorder'); - cy.contains('.list-row-container span', 'frappe.desk.reportview.get').click(); + cy.get('.list-row-container span').contains('frappe.desk.reportview.get').click(); cy.location('hash').should('contain', '#recorder/request/'); cy.get('form').should('contain', 'frappe.desk.reportview.get');