Skip to content

Commit

Permalink
import TEST_USERSNAME directly
Browse files Browse the repository at this point in the history
  • Loading branch information
MatBarba committed Jul 15, 2024
1 parent f01b2ce commit dbb2b4a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/ensembl/utils/database/unittestdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(
db_url = make_url(server_url)
if not name:
name = Path(dump_dir).name if dump_dir else "testdb"
db_name = f"{TEST_USERNAME}_{name}"
db_name = f"{TEST_USERNAME}_{name}"

# Add the database name to the URL
if db_url.get_dialect().name == "sqlite":
Expand Down
10 changes: 3 additions & 7 deletions tests/database/test_dbconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# limitations under the License.
"""Unit testing of `ensembl.utils.database.dbconnection` module."""

import os
from pathlib import Path

import pytest
Expand All @@ -30,9 +29,6 @@
from ensembl.utils.database.unittestdb import TEST_USERNAME


USERNAME = os.environ.get("USER", TEST_USERNAME)


class MockBase(DeclarativeBase):
"""Mock Base for testing."""

Expand Down Expand Up @@ -88,7 +84,7 @@ def test_dialect(self) -> None:
@pytest.mark.dependency(name="test_db_name", depends=["test_init", "test_dialect"], scope="class")
def test_db_name(self) -> None:
"""Tests `DBConnection.db_name` property."""
expected_db_name = f"{USERNAME}_mock_db"
expected_db_name = f"{TEST_USERNAME}_mock_db"
if self.dbc.dialect == "sqlite":
expected_db_name += ".db"
assert self.dbc.db_name == expected_db_name
Expand Down Expand Up @@ -264,7 +260,7 @@ def test_create_all_tables(request: FixtureRequest) -> None:

# Create a test db
db_url = make_url(request.config.getoption("server"))
db_name = f"{USERNAME}_test_create_all_tables"
db_name = f"{TEST_USERNAME}_test_create_all_tables"
db_url = db_url.set(database=db_name)
if database_exists(db_url):
drop_database(db_url)
Expand All @@ -283,7 +279,7 @@ def test_create_table(request: FixtureRequest) -> None:

# Create a test db
db_url = make_url(request.config.getoption("server"))
db_name = f"{USERNAME}_test_create_table"
db_name = f"{TEST_USERNAME}_test_create_table"
db_url = db_url.set(database=db_name)
if database_exists(db_url):
drop_database(db_url)
Expand Down

0 comments on commit dbb2b4a

Please sign in to comment.