Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[23.1] Fix up unit tests for local use #16483

Merged
merged 4 commits into from
Jul 29, 2023

Conversation

mvdbeek
Copy link
Member

@mvdbeek mvdbeek commented Jul 28, 2023

Fixes two little things when running unit tests locally

How to test the changes?

(Select all options that apply)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.
  • Instructions for manual testing are as follows:
    1. [add testing steps and prerequisites here if you didn't write automated tests covering all your changes]

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

@github-actions github-actions bot added this to the 23.2 milestone Jul 28, 2023
mvdbeek and others added 4 commits July 29, 2023 00:46
I see this failing about 50% of the time, and if it fails history1 and
history2 have the same update time.
See https://github.com/ClearcodeHQ/pytest-postgresql#how-to-use

Fix failing queue_worker unit tests when psycopg2 is installed
(otherwise they are skipped):

```
$ pytest test/unit/app/queue_worker/test_database_heartbeat.py::test_database_heartbeat[postgres_app]
...
_________________________________________________________________________ ERROR at setup of test_database_heartbeat[postgres_app] _________________________________________________________________________

request = <SubRequest 'database_app' for <Function test_database_heartbeat[postgres_app]>>

    @pytest.fixture(params=["postgres_app", "sqlite_app", "sqlite_rabbitmq_app"])
    def database_app(request):
        if request.param == "postgres_app":
            if not which("initdb"):
                pytest.skip("initdb must be on PATH for postgresql fixture")
            if not psycopg2:
                pytest.skip("psycopg2 must be installed for postgresql fixture")
        if request.param == "sqlite_rabbitmq_app":
            if not os.environ.get("GALAXY_TEST_AMQP_INTERNAL_CONNECTION"):
                pytest.skip("rabbitmq tests will be skipped if GALAXY_TEST_AMQP_INTERNAL_CONNECTION env var is unset")
>       return request.getfixturevalue(request.param)

test/unit/app/queue_worker/conftest.py:67:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.venv/lib/python3.10/site-packages/pytest_postgresql/factories/process.py:147: in postgresql_proc_fixture
    with DatabaseJanitor(
.venv/lib/python3.10/site-packages/pytest_postgresql/janitor.py:54: in __init__
    check_for_psycopg()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def check_for_psycopg() -> None:
        """
        Function checks whether psycopg was imported.

        Raises ImportError if not.
        """
        if not psycopg:
>           raise ImportError("No module named psycopg. Please install psycopg.")
E           ImportError: No module named psycopg. Please install psycopg.

.venv/lib/python3.10/site-packages/pytest_postgresql/compat.py:35: ImportError
```

Also, remove check for `initdb` in PATH, because on Ubuntu it's installed
in `/usr/lib/postgresql/VERSION/bin/initdb` .
@nsoranzo
Copy link
Member

I've pushed my suggested fix for the psycopg/psycopg2 test skipping, hope that's OK.

I've also pushed here a fix for unit/mypy test breakages due to the forward merge of #16480 .

@mvdbeek mvdbeek merged commit b09b4db into galaxyproject:release_23.1 Jul 29, 2023
38 checks passed
@dannon dannon modified the milestones: 23.2, 23.1 Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants