* added PyMYSQL instead mysqlclient-python * added pymysql import * fixed db module import * foxed self._conn wrapper * updated cursor migration * removed existent converters * some more fixes towards API port * modified travis * updated doctype and revereted yml * modified travis * refreshed logging * raw fix * moved from hard coded constants to declarable instances * moved from hard coded constants to declarable instances * refactoring and logging * moved to global import declaration * fixed codacy * unfixed codacy * minor fix * binary_type has a single * deprecated alternative * merged with latest * fixed merge conflicts * using deprecated alternative * raw fix * stupid fix * using StringTypes instead * brutal hack * log * tundebazy to the rescue * fixed content_hash error * frappe/database.py * frappe/database.py * updated database.py * updated requirements * updated requirements * fixed codacy * fixed codacy * moved from DatabaseOperationalError to pymysql.InternalError * moved from DatabaseOperationalError to pymysql.InternalError * fixed codacy * empty commit * fixed codacy * fixed codacy
29 lines
1.3 KiB
Python
29 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
|
# MIT License. See license.txt
|
|
|
|
from __future__ import unicode_literals
|
|
import unittest
|
|
import frappe
|
|
|
|
class TestDB(unittest.TestCase):
|
|
def test_get_value(self):
|
|
self.assertEquals(frappe.db.get_value("User", {"name": ["=", "Administrator"]}), "Administrator")
|
|
self.assertEquals(frappe.db.get_value("User", {"name": ["like", "Admin%"]}), "Administrator")
|
|
self.assertNotEquals(frappe.db.get_value("User", {"name": ["!=", "Guest"]}), "Guest")
|
|
self.assertEquals(frappe.db.get_value("User", {"name": ["<", "B"]}), "Administrator")
|
|
self.assertEquals(frappe.db.get_value("User", {"name": ["<=", "Administrator"]}), "Administrator")
|
|
|
|
self.assertEquals(frappe.db.sql("""select name from `tabUser` where name > "s" order by modified desc""")[0][0],
|
|
frappe.db.get_value("User", {"name": [">", "s"]}))
|
|
|
|
self.assertEquals(frappe.db.sql("""select name from `tabUser` where name >= "t" order by modified desc""")[0][0],
|
|
frappe.db.get_value("User", {"name": [">=", "t"]}))
|
|
|
|
def test_escape(self):
|
|
frappe.db.escape("香港濟生堂製藥有限公司 - IT".encode("utf-8"))
|
|
|
|
# def test_multiple_queries(self):
|
|
# # implicit commit
|
|
# self.assertRaises(frappe.SQLError, frappe.db.sql, """select name from `tabUser`; truncate `tabEmail Queue`""")
|