-
Notifications
You must be signed in to change notification settings - Fork 0
/
database_test.py
executable file
·53 lines (38 loc) · 1.41 KB
/
database_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python
# Copyright (C) Michael Still ([email protected]) 2009
# Released under the terms of the GNU GPL v2
# Unit tests for mythnettv's database module
import gflags
import os
import sys
import unittest
import MySQLdb
import database
import testsetup
import proxyhandler
FLAGS = gflags.FLAGS
class DatabaseTest(unittest.TestCase):
""" Test the previously erroneous portions of database.py """
def testSingleQuoteEscape(self):
db = database.MythNetTvDatabase(dbname='mythnettv_tests',
dbuser='test',
dbpassword='test',
dbhost='localhost')
self.assertEquals("\"''Banana''\"",
db.FormatSqlValue('string', "'Banana'"))
def testDoubleQuoteEscape(self):
# Double quotes need to be escaped, and strings are returned wrapped in
# double quotes, so we expect _three_ levels of double quotes here.
db = database.MythNetTvDatabase(dbname='mythnettv_tests',
dbuser='test',
dbpassword='test',
dbhost='localhost')
self.assertEquals('"""Banana"""', db.FormatSqlValue('string', '"Banana"'))
if __name__ == "__main__":
# Parse flags
try:
argv = FLAGS(sys.argv)
except gflags.FlagsError, e:
out.write('%s\n' % e)
Usage(out)
unittest.main()