Beispiel #1
0
    def test_ok_wo_where_list(self, model_manager: BaseModelManager, mocker: MockFixture):
        mocked_get_sql = mocker.Mock()

        mocker.patch.object(model_manager, 'get_sql', mocked_get_sql)

        model_manager.where()

        mocked_get_sql.return_value.where.assert_not_called()
Beispiel #2
0
    def test_ok_with_where_list(self, model_manager: BaseModelManager, mocker: MockFixture):
        fake_where_list = ['foo', 'bar']
        mocked_get_sql = mocker.Mock()

        mocker.patch.object(model_manager, 'get_sql', mocked_get_sql)
        mocker.patch.object(model_manager, 'sql')

        model_manager.where(fake_where_list)

        compared_sql = model_manager.sql
        expected_sql = mocked_get_sql.return_value.where.return_value

        calls = [mocker.call(where) for where in fake_where_list]
        mocked_get_sql.return_value.where.assert_has_calls(calls)

        assert compared_sql == expected_sql