diff --git a/agent/tests/test_database.py b/agent/tests/test_database.py index bffb45be..911d6ea2 100644 --- a/agent/tests/test_database.py +++ b/agent/tests/test_database.py @@ -12,7 +12,9 @@ class DatabaseTestInstance: # Test database instance with few utility functions def __init__(self) -> None: self.db_root_password = "123456" - self.db_container = MySqlContainer(image="mysql:8.0", root_password=self.db_root_password) + self.db_container = MySqlContainer( + image="mysql:8.0", MYSQL_ROOT_PASSWORD=self.db_root_password + ) self.db_container.start() @property @@ -44,7 +46,9 @@ def create_database_user(self, db_name: str, username: str, password: str): "FLUSH PRIVILEGES", ] for query in queries: - command = f'mysql -h 127.0.0.1 -uroot -p{self.db_root_password} -e "{query}"' + command = ( + f'mysql -h 127.0.0.1 -uroot -p{self.db_root_password} -e "{query}"' + ) self.execute_cmd(command) @@ -90,11 +94,15 @@ def tearDown(self) -> None: self.instance.destroy() def _db(self, db_name: str, username: str, password: str) -> Database: - return Database(self.instance.host, self.instance.port, username, password, db_name) + return Database( + self.instance.host, self.instance.port, username, password, db_name + ) def test_execute_query(self): """Basic test for `execute_query` function""" db = self._db(self.db1__name, self.db1__username, self.db1__password) - success, data = db.execute_query("SELECT * FROM Person", commit=False, as_dict=True) + success, data = db.execute_query( + "SELECT * FROM Person", commit=False, as_dict=True + ) self.assertEqual(success, True, "run sql query") self.assertEqual(data[0]["row_count"], 5) diff --git a/dev-requirements.txt b/dev-requirements.txt index a1965c81..31076fb2 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,3 +1,3 @@ pre-commit black -testcontainers[mysql]==4.8.2 +testcontainers[mysql]==3.7.1