Пример #1
0
    def test_get_models_hydrates_models(self):
        builder = Builder(self.get_mock_query_builder())
        records = [{'name': 'john', 'age': 26}, {'name': 'jane', 'age': 28}]

        builder.get_query().get = mock.MagicMock(return_value=records)
        model = self.get_mock_model()
        builder.set_model(model)
        model.get_connection_name = mock.MagicMock(
            return_value='foo_connection')
        model.hydrate = mock.MagicMock(return_value=Collection(['hydrated']))
        models = builder.get_models(['foo'])

        self.assertEqual(models.all(), ['hydrated'])

        model.get_table.assert_called_once_with()
        model.get_connection_name.assert_called_once_with()
        model.hydrate.assert_called_once_with(records, 'foo_connection')
    def test_get_models_hydrates_models(self):
        builder = Builder(self.get_mock_query_builder())
        records = [{
            'name': 'john', 'age': 26
        }, {
            'name': 'jane', 'age': 28
        }]

        builder.get_query().get = mock.MagicMock(return_value=records)
        model = self.get_mock_model()
        builder.set_model(model)
        model.get_connection_name = mock.MagicMock(return_value='foo_connection')
        model.hydrate = mock.MagicMock(return_value=Collection(['hydrated']))
        models = builder.get_models(['foo'])

        self.assertEqual(models.all(), ['hydrated'])

        model.get_table.assert_called_once_with()
        model.get_connection_name.assert_called_once_with()
        model.hydrate.assert_called_once_with(
            records, 'foo_connection'
        )
Пример #3
0
    def test_get_models_hydrates_models(self):
        builder = Builder(self.get_mock_query_builder())
        records = Collection([{
            "name": "john",
            "age": 26
        }, {
            "name": "jane",
            "age": 28
        }])

        builder.get_query().get = mock.MagicMock(return_value=records)
        model = self.get_mock_model()
        builder.set_model(model)
        model.get_connection_name = mock.MagicMock(
            return_value="foo_connection")
        model.hydrate = mock.MagicMock(return_value=Collection(["hydrated"]))
        models = builder.get_models(["foo"])

        self.assertEqual(models.all(), ["hydrated"])

        model.get_table.assert_called_once_with()
        model.get_connection_name.assert_called_once_with()
        model.hydrate.assert_called_once_with(records, "foo_connection")