Loading .github/workflows/edge-cloud-management-api.yml +14 −0 Original line number Original line Diff line number Diff line Loading @@ -39,6 +39,20 @@ jobs: - name: Install tox - name: Install tox run: pip install tox run: pip install tox - name: Wait for MongoDB to be ready run: | for i in {30..0}; do if mongo --host localhost --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)'; then echo "MongoDB is up and running" break fi echo 'MongoDB is unavailable - sleeping' sleep 1 done env: MONGO_URI: "mongodb://test_admin:test_password@localhost:27017/test_db?authSource=admin" - name: Run tox for python 3.12 - tests only - name: Run tox for python 3.12 - tests only env: env: MONGO_URI: "mongodb://test_admin:test_password@localhost:27017/test_db?authSource=admin" MONGO_URI: "mongodb://test_admin:test_password@localhost:27017/test_db?authSource=admin" Loading edge_cloud_management_api/managers/db_manager.py +3 −0 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,9 @@ class MongoManager: """ """ Initializes the MongoDB connection using the URI from Config. Initializes the MongoDB connection using the URI from Config. """ """ if not mongo_uri: raise ValueError("MONGO_URI is not set in the environment configuration.") self.client = MongoClient(mongo_uri, maxPoolSize=50) self.client = MongoClient(mongo_uri, maxPoolSize=50) mongo_db_name: str = mongo_uri.split("/")[-1].split("?")[0] mongo_db_name: str = mongo_uri.split("/")[-1].split("?")[0] self.db = self.client[mongo_db_name] self.db = self.client[mongo_db_name] Loading tests/component/controllers/test_app_controllers.py +3 −0 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,9 @@ def mongo_load_apps_collection_data(): """Fixture to insert specific test data into a MongoDB collection before running app controllers tests.""" """Fixture to insert specific test data into a MongoDB collection before running app controllers tests.""" from edge_cloud_management_api.configs.env_config import config from edge_cloud_management_api.configs.env_config import config if not config.MONGO_URI: raise ValueError("MONGO_URI is not set in the environment configuration.") # rely on the loaded environmental variables to maintain consistency across app and tests # rely on the loaded environmental variables to maintain consistency across app and tests client = pymongo.MongoClient(config.MONGO_URI) client = pymongo.MongoClient(config.MONGO_URI) db_name: str = config.MONGO_URI.split("/")[-1].split("?")[0] db_name: str = config.MONGO_URI.split("/")[-1].split("?")[0] Loading tox.ini +1 −0 Original line number Original line Diff line number Diff line Loading @@ -6,6 +6,7 @@ skip_missing_interpreters = true [testenv] [testenv] description = run the tests with pytest description = run the tests with pytest passenv = MONGO_URI package = wheel package = wheel wheel_build_env = .pkg wheel_build_env = .pkg deps = deps = Loading Loading
.github/workflows/edge-cloud-management-api.yml +14 −0 Original line number Original line Diff line number Diff line Loading @@ -39,6 +39,20 @@ jobs: - name: Install tox - name: Install tox run: pip install tox run: pip install tox - name: Wait for MongoDB to be ready run: | for i in {30..0}; do if mongo --host localhost --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)'; then echo "MongoDB is up and running" break fi echo 'MongoDB is unavailable - sleeping' sleep 1 done env: MONGO_URI: "mongodb://test_admin:test_password@localhost:27017/test_db?authSource=admin" - name: Run tox for python 3.12 - tests only - name: Run tox for python 3.12 - tests only env: env: MONGO_URI: "mongodb://test_admin:test_password@localhost:27017/test_db?authSource=admin" MONGO_URI: "mongodb://test_admin:test_password@localhost:27017/test_db?authSource=admin" Loading
edge_cloud_management_api/managers/db_manager.py +3 −0 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,9 @@ class MongoManager: """ """ Initializes the MongoDB connection using the URI from Config. Initializes the MongoDB connection using the URI from Config. """ """ if not mongo_uri: raise ValueError("MONGO_URI is not set in the environment configuration.") self.client = MongoClient(mongo_uri, maxPoolSize=50) self.client = MongoClient(mongo_uri, maxPoolSize=50) mongo_db_name: str = mongo_uri.split("/")[-1].split("?")[0] mongo_db_name: str = mongo_uri.split("/")[-1].split("?")[0] self.db = self.client[mongo_db_name] self.db = self.client[mongo_db_name] Loading
tests/component/controllers/test_app_controllers.py +3 −0 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,9 @@ def mongo_load_apps_collection_data(): """Fixture to insert specific test data into a MongoDB collection before running app controllers tests.""" """Fixture to insert specific test data into a MongoDB collection before running app controllers tests.""" from edge_cloud_management_api.configs.env_config import config from edge_cloud_management_api.configs.env_config import config if not config.MONGO_URI: raise ValueError("MONGO_URI is not set in the environment configuration.") # rely on the loaded environmental variables to maintain consistency across app and tests # rely on the loaded environmental variables to maintain consistency across app and tests client = pymongo.MongoClient(config.MONGO_URI) client = pymongo.MongoClient(config.MONGO_URI) db_name: str = config.MONGO_URI.split("/")[-1].split("?")[0] db_name: str = config.MONGO_URI.split("/")[-1].split("?")[0] Loading
tox.ini +1 −0 Original line number Original line Diff line number Diff line Loading @@ -6,6 +6,7 @@ skip_missing_interpreters = true [testenv] [testenv] description = run the tests with pytest description = run the tests with pytest passenv = MONGO_URI package = wheel package = wheel wheel_build_env = .pkg wheel_build_env = .pkg deps = deps = Loading