2014-11-06 11:08:07 +01:00
|
|
|
import os
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
from dataset.util import FreezeException
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestConfiguration(unittest.TestCase):
|
|
|
|
|
def test_init(self):
|
|
|
|
|
from dataset.freeze.config import Configuration
|
|
|
|
|
|
|
|
|
|
self.assertRaises(FreezeException, Configuration, 'x.x')
|
|
|
|
|
self.assertRaises(FreezeException, Configuration, __file__)
|
|
|
|
|
cfg = Configuration(os.path.join(os.path.dirname(__file__), 'Freezefile.yaml'))
|
2014-11-06 11:16:31 +01:00
|
|
|
assert cfg
|
2014-11-06 11:08:07 +01:00
|
|
|
|
|
|
|
|
def test_exports(self):
|
|
|
|
|
from dataset.freeze.config import Configuration
|
|
|
|
|
|
|
|
|
|
cfg = Configuration(os.path.join(os.path.dirname(__file__), 'Freezefile.yaml'))
|
|
|
|
|
exports = list(cfg.exports)
|
|
|
|
|
self.assertEqual(len(exports), 4)
|
|
|
|
|
self.assertFalse(exports[0].skip)
|
|
|
|
|
self.assertTrue(exports[0].get_bool('bool'))
|
|
|
|
|
self.assertEqual(exports[0].get_int('nan', 'default'), 'default')
|
|
|
|
|
self.assertEqual(exports[0].get_int('number'), 5)
|
2015-01-06 21:57:32 +01:00
|
|
|
self.assertTrue(exports[0].name)
|
2014-11-06 11:16:31 +01:00
|
|
|
|
2014-11-06 11:08:07 +01:00
|
|
|
def test_exports_fail(self):
|
|
|
|
|
from dataset.freeze.config import Configuration
|
|
|
|
|
|
|
|
|
|
cfg = Configuration(os.path.join(os.path.dirname(__file__), 'Freezefile.yaml'))
|
|
|
|
|
cfg.data = None
|
|
|
|
|
self.assertRaises(FreezeException, list, cfg.exports)
|
|
|
|
|
cfg.data = {}
|
|
|
|
|
self.assertRaises(FreezeException, list, cfg.exports)
|
2015-06-08 10:04:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
unittest.main()
|