Exemple #1
0
class LoaderTests(unittest.TestCase):

    def setUp(self):
        from clue_sqlaloader import Loader
        self.session = MockSession()
        self.loader = Loader(self.session)

    def test_load_from_list(self):
        self.loader.load_from_list([
                {'model': 'clue_sqlaloader.tests.MockDataObject',
                 'fields': {'abc': 'ghi'},
                 'execute': {'set_foo': 1}}
                ])
        self.assertEqual(self.session.objects,
                         [MockDataObject(abc='ghi',
                                         foo=1)])

    def test_load_from_yamls(self):
        self.loader.load_from_yamls(
            '- model: clue_sqlaloader.tests.MockDataObject')
        self.assertEqual(self.session.objects,
                         [MockDataObject()])

    def test_load_from_yamlf(self):
        data = '- model: clue_sqlaloader.tests.MockDataObject'

        def mockfile(filename, data=data):
            return MockFile(filename, data)
        self.loader.open = mockfile

        self.loader.load_from_yamlf('foo.yaml')
        self.assertEqual(self.session.objects,
                         [MockDataObject()])
Exemple #2
0
class LoaderTests(unittest.TestCase):
    def setUp(self):
        from clue_sqlaloader import Loader
        self.session = MockSession()
        self.loader = Loader(self.session)

    def test_load_from_list(self):
        self.loader.load_from_list([{
            'model': 'clue_sqlaloader.tests.MockDataObject',
            'fields': {
                'abc': 'ghi'
            },
            'execute': {
                'set_foo': 1
            }
        }])
        self.assertEqual(self.session.objects,
                         [MockDataObject(abc='ghi', foo=1)])

    def test_load_from_yamls(self):
        self.loader.load_from_yamls(
            '- model: clue_sqlaloader.tests.MockDataObject')
        self.assertEqual(self.session.objects, [MockDataObject()])

    def test_load_from_yamlf(self):
        data = '- model: clue_sqlaloader.tests.MockDataObject'

        def mockfile(filename, data=data):
            return MockFile(filename, data)

        self.loader.open = mockfile

        self.loader.load_from_yamlf('foo.yaml')
        self.assertEqual(self.session.objects, [MockDataObject()])
Exemple #3
0
 def setUp(self):
     from clue_sqlaloader import Loader
     self.session = MockSession()
     self.loader = Loader(self.session)
Exemple #4
0
 def setUp(self):
     from clue_sqlaloader import Loader
     self.session = MockSession()
     self.loader = Loader(self.session)