Add tests for the UpdateProcessor.
This commit is contained in:
parent
7ed92ca244
commit
7e1c6d4cfb
1 changed files with 35 additions and 0 deletions
35
tests/test_hub/test_update_processor.py
Normal file
35
tests/test_hub/test_update_processor.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import unittest
|
||||
import mock
|
||||
|
||||
import kojihub
|
||||
|
||||
|
||||
class TestUpdateProcessor(unittest.TestCase):
|
||||
|
||||
def test_basic_instantiation(self):
|
||||
# TODO -- this doesn't make sense. A query with no arguments should
|
||||
# probably raise an exception saying "this doesn't make sense."
|
||||
kojihub.UpdateProcessor('sometable') # No exception!
|
||||
|
||||
def test_to_string_with_data(self):
|
||||
proc = kojihub.UpdateProcessor('sometable', data={'foo': 'bar'})
|
||||
actual = str(proc)
|
||||
expected = 'UPDATE sometable SET foo = %(data.foo)s'
|
||||
self.assertEquals(actual, expected)
|
||||
|
||||
def test_to_values_from_data(self):
|
||||
proc = kojihub.UpdateProcessor('sometable', data={'foo': 'bar'})
|
||||
actual = proc.get_values()
|
||||
expected = {'data.foo': 'bar'}
|
||||
self.assertEquals(actual, expected)
|
||||
|
||||
@mock.patch('kojihub.context')
|
||||
def test_simple_execution_with_iterate(self, context):
|
||||
cursor = mock.MagicMock()
|
||||
context.cnx.cursor.return_value = cursor
|
||||
proc = kojihub.UpdateProcessor('sometable', data={'foo': 'bar'})
|
||||
proc.execute()
|
||||
cursor.execute.assert_called_once_with(
|
||||
'UPDATE sometable SET foo = %(data.foo)s',
|
||||
{'data.foo': 'bar'},
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue