Skip to content

Commit

Permalink
Use relative imports in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carlcsaposs-canonical committed Jan 31, 2023
1 parent 1523fc1 commit 1f33d69
Show file tree
Hide file tree
Showing 20 changed files with 36 additions and 23 deletions.
2 changes: 2 additions & 0 deletions tests/integration/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
4 changes: 2 additions & 2 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import pytest
from pytest_operator.plugin import OpsTest

from tests.integration.integration_constants import SERIES_TO_VERSION
from tests.integration.read_charm_yaml import get_base_versions, get_charm_name
from .integration_constants import SERIES_TO_VERSION
from .read_charm_yaml import get_base_versions, get_charm_name


@pytest.fixture
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
from tenacity import RetryError, Retrying, retry, stop_after_attempt, wait_fixed

from constants import SERVER_CONFIG_USERNAME
from tests.integration.connector import MysqlConnector

from .connector import MysqlConnector

logger = logging.getLogger(__name__)

Expand Down
2 changes: 2 additions & 0 deletions tests/integration/high_availability/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
4 changes: 1 addition & 3 deletions tests/integration/high_availability/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
import pytest
from pytest_operator.plugin import OpsTest

from tests.integration.high_availability.high_availability_helpers import (
get_application_name,
)
from .high_availability_helpers import get_application_name


@pytest.fixture()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pytest_operator.plugin import OpsTest
from tenacity import RetryError, Retrying, stop_after_delay, wait_fixed

from tests.integration.helpers import (
from ..helpers import (
execute_queries_on_unit,
generate_random_string,
get_cluster_status,
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/high_availability/test_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import yaml
from pytest_operator.plugin import OpsTest

from tests.integration.helpers import (
from ..helpers import (
app_name,
cluster_name,
execute_queries_on_unit,
Expand All @@ -20,7 +20,7 @@
get_server_config_credentials,
scale_application,
)
from tests.integration.high_availability.high_availability_helpers import (
from .high_availability_helpers import (
clean_up_database_and_table,
ensure_all_units_continuous_writes_incrementing,
ensure_n_online_mysql_members,
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/high_availability/test_self_healing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from tenacity import RetryError, Retrying, stop_after_attempt, wait_fixed

from constants import CLUSTER_ADMIN_USERNAME, SERVER_CONFIG_USERNAME
from tests.integration.helpers import (

from ..helpers import (
cut_network_from_unit,
execute_queries_on_unit,
get_controller_machine,
Expand All @@ -31,7 +32,7 @@
wait_network_restore,
write_random_chars_to_test_table,
)
from tests.integration.high_availability.high_availability_helpers import (
from .high_availability_helpers import (
clean_up_database_and_table,
ensure_all_units_continuous_writes_incrementing,
ensure_n_online_mysql_members,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/read_charm_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import yaml

from tests.integration.integration_constants import SERIES_TO_VERSION
from .integration_constants import SERIES_TO_VERSION


def get_base_versions(path_to_charmcraft_yaml: Path) -> list[str]:
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/relations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
5 changes: 3 additions & 2 deletions tests/integration/relations/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
ROOT_USERNAME,
SERVER_CONFIG_USERNAME,
)
from tests.integration.helpers import (
from utils import generate_random_password

from ..helpers import (
check_read_only_endpoints,
execute_queries_on_unit,
fetch_credentials,
Expand All @@ -29,7 +31,6 @@
rotate_credentials,
scale_application,
)
from utils import generate_random_password

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/relations/test_db_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import yaml
from pytest_operator.plugin import OpsTest

from tests.integration.helpers import (
from ..helpers import (
execute_queries_on_unit,
get_server_config_credentials,
scale_application,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/relations/test_relation_mysql_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import yaml
from pytest_operator.plugin import OpsTest

from tests.integration.helpers import (
from ..helpers import (
get_legacy_mysql_credentials,
instance_ip,
is_connection_possible,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/relations/test_shared_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import yaml
from pytest_operator.plugin import OpsTest

from tests.integration.helpers import (
from ..helpers import (
execute_queries_on_unit,
get_primary_unit,
get_server_config_credentials,
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/test_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from pytest_operator.plugin import OpsTest

from constants import CLUSTER_ADMIN_USERNAME, TLS_SSL_CERT_FILE
from tests.integration.helpers import (

from .helpers import (
app_name,
get_process_pid,
get_system_user_password,
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
from tenacity import Retrying, stop_after_attempt

from charm import MySQLOperatorCharm
from tests.unit.helpers import patch_network_get

from .helpers import patch_network_get


class TestCharm(unittest.TestCase):
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

from charm import MySQLOperatorCharm
from constants import DB_RELATION_NAME
from tests.unit.helpers import patch_network_get

from .helpers import patch_network_get


class TestDatase(unittest.TestCase):
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_db_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from ops.testing import Harness

from charm import MySQLOperatorCharm
from tests.unit.helpers import patch_network_get

from .helpers import patch_network_get


class TestDBRouter(unittest.TestCase):
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_relation_mysql_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

from charm import MySQLOperatorCharm
from constants import LEGACY_MYSQL, PEER
from tests.unit.helpers import patch_network_get

from .helpers import patch_network_get


class TestMariaDBRelation(unittest.TestCase):
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_shared_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

from charm import MySQLOperatorCharm
from constants import LEGACY_DB_SHARED
from tests.unit.helpers import patch_network_get

from .helpers import patch_network_get


class TestSharedDBRelation(unittest.TestCase):
Expand Down

0 comments on commit 1f33d69

Please sign in to comment.