Repository: heavyai/sqlalchemy-heavyai (language: python)

Issue:
DOC: Replace the name of the package from sqlalchemy_omnisci to sqlalchemy-omnisci
In the documentation there are some usage of the name of the package, such as the repository name, etc and it is using `sqlalchemy_omnisci` instead of `sqlalchemy-omnisci`.


Discussion / hints:

Fix patch:
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 4b314a3..1a9cc06 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -9,7 +9,7 @@ You can contribute in many ways:
 
 ### Report Bugs
 
-Report bugs at https://github.com/omnisci/sqlalchemy_omnisci/issues.
+Report bugs at https://github.com/omnisci/sqlalchemy-omnisci/issues.
 
 If you are reporting a bug, please include:
 
@@ -35,7 +35,7 @@ articles, and such.
 
 ### Submit Feedback
 
-The best way to send feedback is to file an issue at https://github.com/omnisci/sqlalchemy_omnisci/issues.
+The best way to send feedback is to file an issue at https://github.com/omnisci/sqlalchemy-omnisci/issues.
 
 If you are proposing a feature:
 
@@ -46,18 +46,19 @@ If you are proposing a feature:
 
 ### Get Started!
 
-Ready to contribute? Here's how to set up `sqlalchemy_omnisci` for local development.
+Ready to contribute? Here's how to set up `sqlalchemy-omnisci` for local development.
 
-1. Fork the `sqlalchemy_omnisci` repo on GitHub.
+1. Fork the `sqlalchemy-omnisci` repo on GitHub.
 2. Clone your fork locally::
 ```sh
-    $ git clone git@github.com:your_name_here/sqlalchemy_omnisci.git
+    $ git clone git@github.com:your_name_here/sqlalchemy-omnisci.git
 ```
-3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
+1. Create a conda environment and set up your fork for local development::
 ```sh
-    $ mkvirtualenv sqlalchemy_omnisci
-    $ cd sqlalchemy_omnisci/
-    $ python setup.py develop
+    $ cd sqlalchemy-omnisci/
+    $ conda env create --file environment.yaml
+    $ conda activate sqla-omnisci
+    $ make develop
 ```
 4. Create a branch for local development::
 ```sh
@@ -65,21 +66,13 @@ Ready to contribute? Here's how to set up `sqlalchemy_omnisci` for local develop
 ```
    Now you can make your changes locally.
 
-5. When you're done making changes, check that your changes pass flake8 and the
-   tests, including testing other Python versions with tox::
-```sh
-    $ flake8 sqlalchemy_omnisci tests
-    $ python setup.py test or py.test
-```
-   To get flake8 and tox, just pip install them into your virtualenv.
-
-6. Commit your changes and push your branch to GitHub::
+5. Commit your changes and push your branch to GitHub (this runs pre-commit hooks automatically)::
 ```
     $ git add .
     $ git commit -m "Your detailed description of your changes."
     $ git push origin name-of-your-bugfix-or-feature
 ```
-7. Submit a pull request through the GitHub website.
+6. Submit a pull request through the GitHub website.
 
 ## Pull Request Guidelines
 
@@ -88,17 +81,8 @@ Before you submit a pull request, check that it meets these guidelines:
 1. The pull request should include tests.
 2. If the pull request adds functionality, the docs should be updated. Put
    your new functionality into a function with a docstring, and add the
-   feature to the list in README.rst.
-3. The pull request should work for Python 3.6, 3.7 and 3.8, and for PyPy. Check
-   https://travis-ci.org/omnisci/sqlalchemy_omnisci/pull_requests
-   and make sure that the tests pass for all supported Python versions.
-
-## Tips
+   feature to the list in README.md.
 
-To run a subset of tests::
-```sh
-    $ py.test tests.test_sqlalchemy_omnisci
-```
 
 ## Deploying
 
@@ -107,8 +91,4 @@ Make sure all your changes are committed (including an entry in HISTORY.md).
 
 Then run:
 
-```sh
-$ bumpversion patch # possible: major / minor / patch
-$ git push
-$ git push --tags
-```
+**TBD**
diff --git a/Makefile b/Makefile
index e58d230..6e96687 100644
--- a/Makefile
+++ b/Makefile
@@ -85,7 +85,6 @@ install: clean ## install the package to the active Python's site-packages
 
 develop: clean ## install the package in development mode
 	pip install -e '.[dev]'
-	git init  # it is safe to run it more than one time
 	pre-commit install
 
 
@@ -106,12 +105,16 @@ docker-omnisci-build:
 
 docker-omnisci-start:
 	$(DOCKER) up -d omniscidb
-	$(DOCKER) logs -f omniscidb
+	$(DOCKER) logs -f --tail=100 omniscidb
 
 docker-omnisci-run:
 	$(DOCKER) run omniscidb
 
 
+docker-omnisci-bash:
+	$(DOCKER) exec omniscidb bash
+
+
 # tests
 
 # skipping for the following tests because they breaking the tests
@@ -225,4 +228,4 @@ not (\
 endef
 
 run-tests:
-	pytest -vv -k "${PYTEST_EXPR}" ${TEST_PARAMS} tests/test_suite.py
+	pytest -vv -k "${PYTEST_EXPR}" ${TEST_PARAMS} tests/
diff --git a/docs/installation.rst b/docs/installation.rst
index 5d76acf..6befde7 100644
--- a/docs/installation.rst
+++ b/docs/installation.rst
@@ -12,7 +12,7 @@ To install SQLAlchemy OmniSci, run this command in your terminal:
 
 .. code-block:: console
 
-    $ pip install sqlalchemy_omnisci
+    $ pip install sqlalchemy-omnisci
 
 This is the preferred method to install SQLAlchemy OmniSci, as it will always install the most recent stable release.
 
@@ -32,13 +32,13 @@ You can either clone the public repository:
 
 .. code-block:: console
 
-    $ git clone git://github.com/omnisci/sqlalchemy_omnisci
+    $ git clone git://github.com/omnisci/sqlalchemy-omnisci
 
 Or download the `tarball`_:
 
 .. code-block:: console
 
-    $ curl  -OL https://github.com/omnisci/sqlalchemy_omnisci/tarball/master
+    $ curl  -OL https://github.com/omnisci/sqlalchemy-omnisci/tarball/master
 
 Once you have a copy of the source, you can install it with:
 
@@ -47,5 +47,5 @@ Once you have a copy of the source, you can install it with:
     $ python setup.py install
 
 
-.. _Github repo: https://github.com/omnisci/sqlalchemy_omnisci
-.. _tarball: https://github.com/omnisci/sqlalchemy_omnisci/tarball/master
+.. _Github repo: https://github.com/omnisci/sqlalchemy-omnisci
+.. _tarball: https://github.com/omnisci/sqlalchemy-omnisci/tarball/master
diff --git a/docs/usage.rst b/docs/usage.rst
index 0c0bbdc..9b3a3e4 100644
--- a/docs/usage.rst
+++ b/docs/usage.rst
@@ -2,6 +2,12 @@
 Usage
 =====
 
-To use SQLAlchemy OmniSci in a project::
+To use SQLAlchemy OmniSci to connect to a local OmniSci server::
 
-    import sqlalchemy_omnisci
+    from sqlalchemy import create_engine
+
+    # uri: omnisci://<user>:<pass>@<host>:<port>/<db>?protocol=<protocol>
+    engine = create_engine(
+        "omnisci://admin:HyperInteractive@"
+        "localhost:6274/omnisci?protocol=binary"
+    )
diff --git a/setup.cfg b/setup.cfg
index d54bc3c..8dee1f5 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -22,11 +22,11 @@ test = pytest
 
 [tool:pytest]
 addopts= --tb native -v -r fxX -p no:warnings
-python_files=tests/test_*.py
+python_files=tests/*test_*.py
 
 [sqla_testing]
 requirement_cls=sqlalchemy_omnisci.requirements:Requirements
-profile_file=.profiles.txt
+profile_file=tests/profiles.txt
 
 [db]
-default=omnisci://admin:HyperInteractive@localhost:6274/omnisci?protocol=binary
+default=omnisci://admin:HyperInteractive@localhost:6274/sqla_testing?protocol=binary


Test patch:
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 0000000..479e123
--- /dev/null
+++ b/tests/__init__.py
@@ -0,0 +1,1 @@
+"""Package for testing."""
diff --git a/tests/conftest.py b/tests/conftest.py
index 334660b..55f63e4 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -16,21 +16,38 @@
     SmallInteger,
     String,
     create_engine,
+    testing,
 )
 from sqlalchemy.sql import column, table
 
 from sqlalchemy_omnisci import URL
 
-# registry.register("omnisci", "sqlalchemy_omnisci", "OmniSciDialect")
+URI_TEMPLATE = (
+    "omnisci://{user}:{password}@{database}:{port}/{database}"
+    "?protocol={protocol}"
+)
 
-os.environ["SQLALCHEMY_WARN_20"] = "true"
+DATABASE_TESTING = "sqla_testing"
 
-pytest.register_assert_rewrite("sqlalchemy.testing.assertions")
+DEFAULT_PARAMETERS = {
+    "user": "admin",
+    "password": "HyperInteractive",
+    "database": DATABASE_TESTING,
+    "protocol": "binary",
+    "host": "localhost",
+    "port": "6274",
+}
 
-# this happens after pytest.register_assert_rewrite to avoid pytest warning
-from sqlalchemy.testing.plugin.pytestplugin import *  # noqa: F401, E402, F403
+SETUP_PARAMETERS = {
+    "user": "admin",
+    "password": "HyperInteractive",
+    "database": "omnisci",
+    "protocol": "binary",
+    "host": "localhost",
+    "port": "6274",
+}
 
-DEFAULT_PARAMETERS = {
+METIS_PARAMETERS = {
     "user": "demouser",
     "password": "HyperInteractive",
     "database": "mapd",
@@ -40,9 +57,9 @@
 }
 
 
-def get_db_parameters():
+def get_db_parameters(db_params=DEFAULT_PARAMETERS):
     """Set the db connection parameters."""
-    ret = copy.copy(DEFAULT_PARAMETERS)
+    ret = copy.copy(db_params)
 
     # a unique table name
     ret["name"] = ("sqlalchemy_tests_" + str(uuid.uuid4())).replace("-", "_")
@@ -50,9 +67,9 @@ def get_db_parameters():
     return ret
 
 
-def get_engine(user=None, password=None):
+def get_engine(user=None, password=None, db_params=DEFAULT_PARAMETERS):
     """Create a connection using the given parameters."""
-    ret = get_db_parameters()
+    ret = get_db_parameters(db_params)
 
     if user is not None:
         ret["user"] = user
@@ -74,6 +91,18 @@ def get_engine(user=None, password=None):
     return engine, ret
 
 
+@pytest.fixture(autouse=True, scope="session")
+def uri_metis():
+    """Return a URI for metis server."""
+    return URI_TEMPLATE.format(**METIS_PARAMETERS)
+
+
+@pytest.fixture(autouse=True, scope="session")
+def uri_local():
+    """Return a URI for local server."""
+    return URI_TEMPLATE.format(**DEFAULT_PARAMETERS)
+
+
 @pytest.fixture(autouse=True)
 def table_datatype():
     """Create a table expression for handle different datatypes."""
@@ -121,13 +150,27 @@ def engine_testaccount(request):
     return engine
 
 
-@pytest.hookimpl(hookwrapper=True)
-def pytest_pyfunc_call(pyfuncitem):
-    """Add dynamically an xfail marker for specific backends."""
-    outcome = yield
-    success = True
+os.environ["SQLALCHEMY_WARN_20"] = "true"
+
+pytest.register_assert_rewrite("sqlalchemy.testing.assertions")
+
+# this happens after pytest.register_assert_rewrite to avoid pytest warning
+from sqlalchemy.testing.plugin.pytestplugin import *  # noqa: F401, E402, F403
+
 
+def pytest_sessionstart(session):
+    """Run a hook for pytest sessionstart."""
+    engine, _ = get_engine(db_params=SETUP_PARAMETERS)
     try:
-        outcome.get_result()
-    except Exception as e:
-        pytest.xfail(reason=repr(e))
+        engine.execute(f"DROP DATABASE {DATABASE_TESTING};")
+    except:
+        ...
+    engine.execute(f"CREATE DATABASE {DATABASE_TESTING};")
+    testing.plugin.pytestplugin.pytest_sessionstart(session)
+
+
+def pytest_sessionfinish(session, exitstatus):
+    """Run a hook for pytest sessionfinish."""
+    engine, _ = get_engine(db_params=SETUP_PARAMETERS)
+    # engine.execute(f"DROP DATABASE {DATABASE_TESTING};")
+    testing.plugin.pytestplugin.pytest_sessionfinish(session)
diff --git a/tests/test_compiler.py b/tests/test_compiler.py
index 7598f58..9741768 100644
--- a/tests/test_compiler.py
+++ b/tests/test_compiler.py
@@ -2,10 +2,10 @@
 import pytest
 from sqlalchemy import func, select
 from sqlalchemy.sql import column, quoted_name, table
-from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import AssertsCompiledSQL, fixtures
 
 
-class _TestCompilerOmniSci(AssertsCompiledSQL):
+class _TestCompilerOmniSci(fixtures.TestBase, AssertsCompiledSQL):
     __dialect__ = "omnisci"
 
 
@@ -56,6 +56,40 @@ def test_select_datatype_table_avg(self, table_datatype, sql_func):
             dialect="omnisci",
         )
 
+    def test_quoted_name_label(self):
+        """Test quoted name label."""
+        test_cases = [
+            # quote name
+            {
+                "label": quoted_name("alias", True),
+                "output": (
+                    'SELECT colname AS "alias" \nFROM abc GROUP BY colname'
+                ),
+            },
+            # not quote label
+            {
+                "label": "alias",
+                "output": (
+                    "SELECT colname AS alias \nFROM abc GROUP BY colname"
+                ),
+            },
+            # not quote mixed case label
+            {
+                "label": "Alias",
+                "output": (
+                    'SELECT colname AS "Alias" \nFROM abc GROUP BY colname'
+                ),
+            },
+        ]
+
+        for t in test_cases:
+            col = column("colname").label(t["label"])
+            sel_from_tbl = (
+                select([col]).group_by(col).select_from(table("abc"))
+            )
+            compiled_result = sel_from_tbl.compile()
+            assert str(compiled_result) == t["output"]
+
 
 class TestCompilerDelete(_TestCompilerOmniSci):
     """Compilation test for delete statement."""
@@ -82,30 +116,3 @@ def test_table_update(self, table1):
             "WHERE table1.name = %(name_1)s",
             dialect="omnisci",
         )
-
-
-def test_quoted_name_label():
-    """Test quoted name label."""
-    test_cases = [
-        # quote name
-        {
-            "label": quoted_name("alias", True),
-            "output": 'SELECT colname AS "alias" \nFROM abc GROUP BY colname',
-        },
-        # not quote label
-        {
-            "label": "alias",
-            "output": "SELECT colname AS alias \nFROM abc GROUP BY colname",
-        },
-        # not quote mixed case label
-        {
-            "label": "Alias",
-            "output": 'SELECT colname AS "Alias" \nFROM abc GROUP BY colname',
-        },
-    ]
-
-    for t in test_cases:
-        col = column("colname").label(t["label"])
-        sel_from_tbl = select([col]).group_by(col).select_from(table("abc"))
-        compiled_result = sel_from_tbl.compile()
-        assert str(compiled_result) == t["output"]
diff --git a/tests/test_connection.py b/tests/test_connection.py
new file mode 100644
index 0000000..7f76137
--- /dev/null
+++ b/tests/test_connection.py
@@ -0,0 +1,15 @@
+"""Tests for connection."""
+import sqlalchemy
+from sqlalchemy.testing import fixtures
+
+
+class ConnectionTest(fixtures.TestBase):
+    """Test connection."""
+
+    def test_metis_connection(self, uri_metis):
+        """Test connection to metis server using https protocol."""
+        sqlalchemy.create_engine(uri_metis)
+
+    def test_local_connection(self, uri_local):
+        """Test connection to local server using binary protocol."""
+        sqlalchemy.create_engine(uri_local)