Permalink
Browse files

Fix a test

  • Loading branch information...
1 parent 70e68f6 commit db4149ea188b98c650f974cec3ec7798228b6bcc Luke Marsden committed Aug 16, 2011
Showing with 15 additions and 12 deletions.
  1. +0 −4 HybridUtils.py
  2. +1 −2 txmysql/client.py
  3. +14 −6 txmysql/test/test_txmysql.py
View
@@ -1,7 +1,6 @@
import time
import re
import os
-import socket
import sys
import pprint
import inspect
@@ -10,9 +9,6 @@
from twisted.spread import pb
from twisted.internet import abstract,fdesc,threads
from twisted.python import log, failure
-from twisted.python.util import untilConcludes
-from twisted.enterprise import adbapi
-from MySQLdb import OperationalError, ProgrammingError
from collections import defaultdict
from twisted.web.client import Agent
View
@@ -4,9 +4,8 @@
from txmysql import error
from twisted.python.failure import Failure
import pprint
-import functools
-DEBUG = True
+DEBUG = False
def _escape(query, args=None): # XXX: Add Rob's suggestion for escaping
# TODO: Turn %% into % so that you can do a real %s
@@ -7,6 +7,9 @@
TODO: Check code coverage for every line, then manually any compound expression
in a conditional to check that there is test case coverage for each case.
+
+Please CREATE DATABASE foo and grant the appropriate credentials before running
+this test suite.
"""
import os, pwd, sys
from errno import ENOENT
@@ -147,15 +150,18 @@ def and_start(data):
@defer.inlineCallbacks
def test_0050_test_initial_database_selection(self):
"""
- 1. Start MySQL
- 2. Connect
- 3. Query - check result
+ Check that when we connect to a database in the initial handshake, we
+ end up in the 'foo' database. TOOD: Check that we're actually in the
+ 'foo' database somehow.
"""
yield self._start_mysql()
- conn = self._connect_mysql()
- result = yield conn.runQuery("select * from foo")
+ conn = self._connect_mysql(database='foo')
+ result = yield conn.runOperation("create table if not exists foo (id int primary key)")
+ result = yield conn.runOperation("delete from foo.foo")
+ result = yield conn.runOperation("insert into foo.foo set id=191919")
+ result = yield conn.runQuery("select * from foo order by id desc limit 1")
conn.disconnect()
- self.assertEquals(result, [[1]])
+ self.assertEquals(result, [[191919]])
@defer.inlineCallbacks
def test_0100_start_connect_query(self):
@@ -413,3 +419,5 @@ def _connect_mysql(self, **kw):
return client.MySQLConnection('127.0.0.1', 'root', secrets.MYSQL_ROOT_PASS, **kw)
else:
return client.MySQLConnection('127.0.0.1', 'root', secrets.MYSQL_ROOT_PASS, 'foo', **kw)
+
+

0 comments on commit db4149e

Please sign in to comment.