diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py new file mode 100644 index 000000000..db3bfe1a6 --- /dev/null +++ b/tests/integration/__init__.py @@ -0,0 +1,2 @@ +# Copyright 2023 Canonical Ltd. +# See LICENSE file for licensing details. diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index b4c923851..5d00a7f1b 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -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 diff --git a/tests/integration/helpers.py b/tests/integration/helpers.py index 5d3a54639..19c63b058 100644 --- a/tests/integration/helpers.py +++ b/tests/integration/helpers.py @@ -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__) diff --git a/tests/integration/high_availability/__init__.py b/tests/integration/high_availability/__init__.py new file mode 100644 index 000000000..db3bfe1a6 --- /dev/null +++ b/tests/integration/high_availability/__init__.py @@ -0,0 +1,2 @@ +# Copyright 2023 Canonical Ltd. +# See LICENSE file for licensing details. diff --git a/tests/integration/high_availability/conftest.py b/tests/integration/high_availability/conftest.py index cf65fdcab..748920f75 100644 --- a/tests/integration/high_availability/conftest.py +++ b/tests/integration/high_availability/conftest.py @@ -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() diff --git a/tests/integration/high_availability/high_availability_helpers.py b/tests/integration/high_availability/high_availability_helpers.py index 6ccf431df..f36682b76 100644 --- a/tests/integration/high_availability/high_availability_helpers.py +++ b/tests/integration/high_availability/high_availability_helpers.py @@ -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, diff --git a/tests/integration/high_availability/test_replication.py b/tests/integration/high_availability/test_replication.py index b280c112a..33c28fcc2 100644 --- a/tests/integration/high_availability/test_replication.py +++ b/tests/integration/high_availability/test_replication.py @@ -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, @@ -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, diff --git a/tests/integration/high_availability/test_self_healing.py b/tests/integration/high_availability/test_self_healing.py index 635813a95..579685d76 100644 --- a/tests/integration/high_availability/test_self_healing.py +++ b/tests/integration/high_availability/test_self_healing.py @@ -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, @@ -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, diff --git a/tests/integration/read_charm_yaml.py b/tests/integration/read_charm_yaml.py index c210417fe..961919958 100644 --- a/tests/integration/read_charm_yaml.py +++ b/tests/integration/read_charm_yaml.py @@ -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]: diff --git a/tests/integration/relations/__init__.py b/tests/integration/relations/__init__.py new file mode 100644 index 000000000..db3bfe1a6 --- /dev/null +++ b/tests/integration/relations/__init__.py @@ -0,0 +1,2 @@ +# Copyright 2023 Canonical Ltd. +# See LICENSE file for licensing details. diff --git a/tests/integration/relations/test_database.py b/tests/integration/relations/test_database.py index d41c67f0a..3194eadeb 100644 --- a/tests/integration/relations/test_database.py +++ b/tests/integration/relations/test_database.py @@ -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, @@ -29,7 +31,6 @@ rotate_credentials, scale_application, ) -from utils import generate_random_password logger = logging.getLogger(__name__) diff --git a/tests/integration/relations/test_db_router.py b/tests/integration/relations/test_db_router.py index 8597ac7ac..3099ed814 100644 --- a/tests/integration/relations/test_db_router.py +++ b/tests/integration/relations/test_db_router.py @@ -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, diff --git a/tests/integration/relations/test_relation_mysql_legacy.py b/tests/integration/relations/test_relation_mysql_legacy.py index e1c0ca56e..6af8ba982 100644 --- a/tests/integration/relations/test_relation_mysql_legacy.py +++ b/tests/integration/relations/test_relation_mysql_legacy.py @@ -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, diff --git a/tests/integration/relations/test_shared_db.py b/tests/integration/relations/test_shared_db.py index 52b2b3a74..273670edf 100644 --- a/tests/integration/relations/test_shared_db.py +++ b/tests/integration/relations/test_shared_db.py @@ -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, diff --git a/tests/integration/test_tls.py b/tests/integration/test_tls.py index 58cd4d633..e0616aca7 100644 --- a/tests/integration/test_tls.py +++ b/tests/integration/test_tls.py @@ -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, diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py index bfdb2eec9..a942ce451 100644 --- a/tests/unit/test_charm.py +++ b/tests/unit/test_charm.py @@ -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): diff --git a/tests/unit/test_database.py b/tests/unit/test_database.py index 7dc8e4036..b34f8f866 100644 --- a/tests/unit/test_database.py +++ b/tests/unit/test_database.py @@ -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): diff --git a/tests/unit/test_db_router.py b/tests/unit/test_db_router.py index a800c6895..6ab03934e 100644 --- a/tests/unit/test_db_router.py +++ b/tests/unit/test_db_router.py @@ -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): diff --git a/tests/unit/test_relation_mysql_legacy.py b/tests/unit/test_relation_mysql_legacy.py index 34c057ef8..4e6a69aaf 100644 --- a/tests/unit/test_relation_mysql_legacy.py +++ b/tests/unit/test_relation_mysql_legacy.py @@ -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): diff --git a/tests/unit/test_shared_db.py b/tests/unit/test_shared_db.py index 187b8d61b..3c65d3f0f 100644 --- a/tests/unit/test_shared_db.py +++ b/tests/unit/test_shared_db.py @@ -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):