make dataset.freeze.config compatible with python3
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
common:
|
||||
|
||||
database: "postgresql://user:password@localhost/operational_database"
|
||||
prefix: my_project/dumps/
|
||||
format: json
|
||||
nested:
|
||||
|
||||
property: "inner"
|
||||
|
||||
exports:
|
||||
|
||||
- query: "SELECT id, title, date FROM events"
|
||||
filename: "index.json"
|
||||
number: 5
|
||||
bool: true
|
||||
nested:
|
||||
|
||||
property: "override"
|
||||
|
||||
- query: "SELECT id, title, date, country FROM events"
|
||||
filename: "countries/{{country}}.csv"
|
||||
format: csv
|
||||
|
||||
- query: "SELECT * FROM events"
|
||||
filename: "events/{{id}}.json"
|
||||
mode: item
|
||||
wrap: true
|
||||
|
||||
- query: "SELECT * FROM events"
|
||||
filename: "all.json"
|
||||
format: tabson
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
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'))
|
||||
|
||||
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)
|
||||
self.assert_(exports[0].name)
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user