2012-03-28 05:45:49 +00:00
|
|
|
import integration
|
2012-05-05 14:09:23 +00:00
|
|
|
|
2012-03-28 05:45:49 +00:00
|
|
|
|
|
|
|
class DataModuleTest(integration.ModuleCase):
|
|
|
|
'''
|
|
|
|
Validate the data module
|
|
|
|
'''
|
|
|
|
def _clear_db(self):
|
|
|
|
'''
|
|
|
|
Clear out the database
|
|
|
|
'''
|
|
|
|
self.run_function('data.clear')
|
|
|
|
|
|
|
|
def test_load_dump(self):
|
|
|
|
'''
|
|
|
|
data.load
|
|
|
|
data.dump
|
|
|
|
'''
|
|
|
|
self._clear_db()
|
|
|
|
self.assertTrue(self.run_function('data.dump', ['{"foo": "bar"}']))
|
|
|
|
self.assertEqual(self.run_function('data.load'), {'foo': 'bar'})
|
|
|
|
self._clear_db()
|
|
|
|
|
|
|
|
def test_get_update(self):
|
|
|
|
'''
|
|
|
|
data.getval
|
|
|
|
data.update
|
|
|
|
data.getvals
|
|
|
|
'''
|
|
|
|
self._clear_db()
|
|
|
|
self.assertTrue(
|
|
|
|
self.run_function(
|
|
|
|
'data.update',
|
|
|
|
['spam', 'eggs']
|
|
|
|
)
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
self.run_function(
|
|
|
|
'data.getval',
|
|
|
|
['spam']
|
|
|
|
),
|
|
|
|
'eggs'
|
|
|
|
)
|
|
|
|
self.assertTrue(
|
|
|
|
self.run_function(
|
|
|
|
'data.update',
|
|
|
|
['unladen', 'swallow']
|
|
|
|
)
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
self.run_function(
|
|
|
|
'data.getvals',
|
2012-07-20 03:35:23 +00:00
|
|
|
['spam', 'unladen']
|
2012-03-28 05:45:49 +00:00
|
|
|
),
|
2012-07-23 19:00:54 +00:00
|
|
|
['eggs', 'swallow']
|
2012-03-28 05:45:49 +00:00
|
|
|
)
|
|
|
|
self._clear_db()
|
|
|
|
|
2012-07-20 06:21:01 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
from integration import run_tests
|
|
|
|
run_tests(DataModuleTest)
|