Skip to content

Commit

Permalink
feat: add sqlalchemy tests (4paradigm#1756)
Browse files Browse the repository at this point in the history
* Create requirements.py

* Create setup.cfg

* Create conftest.py

* Update conftest.py

* Create sqlalchemy_standardtest_example.py

* Update setup.py

* Update sqlalchemy_standardtest_example.py

* Update setup.cfg

* Rename setup.cfg to sqlalchemy_test_config

* Update conftest.py

Co-authored-by: HuilinWu2 <[email protected]>
  • Loading branch information
tobegit3hub and HuilinWu2 authored Jul 8, 2022
1 parent 816db70 commit 79143ed
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 0 deletions.
88 changes: 88 additions & 0 deletions python/openmldb/sqlalchemy_openmldb/requirements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
from sqlalchemy.testing.requirements import SuiteRequirements

from sqlalchemy.testing import exclusions


class Requirements(SuiteRequirements):
@property
def bound_limit_offset(self):
return exclusions.closed()

@property
def date(self):
return exclusions.closed()

@property
def datetime_microseconds(self):
return exclusions.closed()

@property
def floats_to_four_decimals(self):
return exclusions.closed()

# TODO: remove this when SQLA released with
# https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/2990
@property
def implicitly_named_constraints(self):
return exclusions.open()

@property
def nullable_booleans(self):
"""Target database allows boolean columns to store NULL."""
# Access Yes/No doesn't allow null
return exclusions.closed()

@property
def offset(self):
# Access does LIMIT (via TOP) but not OFFSET
return exclusions.closed()

@property
def parens_in_union_contained_select_w_limit_offset(self):
return exclusions.closed()

@property
def precision_generic_float_type(self):
return exclusions.closed()

@property
def reflects_pk_names(self):
return exclusions.open()

@property
def sql_expression_limit_offset(self):
return exclusions.closed()

@property
def temp_table_reflection(self):
return exclusions.closed()

@property
def temporary_tables(self):
return exclusions.closed()

@property
def temporary_views(self):
return exclusions.closed()

@property
def time(self):
return exclusions.closed()

@property
def time_microseconds(self):
return exclusions.closed()

@property
def timestamp_microseconds(self):
return exclusions.closed()

@property
def unicode_ddl(self):
# Access won't let you drop a child table unless
# you drop the FK constraint first. Not worth the grief.
return exclusions.closed()

@property
def view_column_reflection(self):
return exclusions.open()
26 changes: 26 additions & 0 deletions python/openmldb/sqlalchemy_test_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2021 4Paradigm
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [tool:pytest]
# addopts= --tb native -v -r fxX --maxfail=25 -p no:warnings
# python_files=/openmldb/test/*test_*.py

# [sqla_testing]
# requirement_cls=openmldb.sqlalchemy_openmldb.requirements:Requirements
# profile_file=test/profiles.txt

# [db]
# default = openmldb:///db_test?zk=127.0.0.1:6181&zkPath=/onebox
24 changes: 24 additions & 0 deletions python/openmldb/test/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2021 4Paradigm
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from sqlalchemy.dialects import registry
import pytest

# registry.register("openmldb", "openmldb.sqlalchemy_openmldb.openmldb_dialect", "OpenmldbDialect")

# pytest.register_assert_rewrite("sqlalchemy.testing.assertions")

# from sqlalchemy.testing.plugin.pytestplugin import *
27 changes: 27 additions & 0 deletions python/openmldb/test/sqlalchemy_standardtest_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2021 4Paradigm
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from sqlalchemy.testing.suite import *

from sqlalchemy.testing.suite import IntegerTest as _IntegerTest

# class IntegerTest(_IntegerTest):

# @testing.skip("access")
# def test_huge_int(self):
# # bypass this test because Access ODBC fails with
# # [ODBC Microsoft Access Driver] Optional feature not implemented.
# return
1 change: 1 addition & 0 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"sqlalchemy < 1.4.0",
"IPython",
"prettytable",
"tox",
"pytest"
],
include_package_data=True,
Expand Down

0 comments on commit 79143ed

Please sign in to comment.