Commit aad20b0a authored by Karagkounis Dimitris's avatar Karagkounis Dimitris
Browse files

allow tox to use exported env variables

parent 94cbd489
Loading
Loading
Loading
Loading
+14 −0
Changes for .github/workflows/edge-cloud-management-api.yml: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -39,6 +39,20 @@ jobs:
      - name: 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
        env:
          MONGO_URI: "mongodb://test_admin:test_password@localhost:27017/test_db?authSource=admin"
+3 −0
Changes for edge_cloud_management_api/managers/db_manager.py: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -25,6 +25,9 @@ class MongoManager:
        """
        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)
        mongo_db_name: str = mongo_uri.split("/")[-1].split("?")[0]
        self.db = self.client[mongo_db_name]
+3 −0
Changes for tests/component/controllers/test_app_controllers.py: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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."""
    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
    client = pymongo.MongoClient(config.MONGO_URI)
    db_name: str = config.MONGO_URI.split("/")[-1].split("?")[0]
+1 −0
Changes for tox.ini: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ skip_missing_interpreters = true

[testenv]
description = run the tests with pytest
passenv = MONGO_URI
package = wheel
wheel_build_env = .pkg
deps =