示例#1
0
    def test_get_value(self):
        server = FrappeClient(get_url(),
                              "Administrator",
                              "admin",
                              verify=False)
        frappe.db.sql("delete from `tabNote` where title = 'get_value'")
        frappe.db.commit()

        test_content = "test get value"

        server.insert_many([
            {
                "doctype": "Note",
                "public": True,
                "title": "get_value",
                "content": test_content
            },
        ])
        self.assertEqual(
            server.get_value("Note", "content", {
                "title": "get_value"
            }).get('content'), test_content)
        name = server.get_value("Note", "name", {
            "title": "get_value"
        }).get('name')

        # test by name
        self.assertEqual(
            server.get_value("Note", "content", name).get('content'),
            test_content)

        self.assertRaises(
            FrappeException, server.get_value, "Note",
            "(select (password) from(__Auth) order by name desc limit 1)",
            {"title": "get_value"})
示例#2
0
 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', '')
示例#3
0
 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", "")