Loading tests/fixtures/edge-cloud-zones.json 0 → 100644 +23 −0 Changes for tests/fixtures/edge-cloud-zones.json: 23 added lines, 0 removed lines. Original line number Diff line number Diff line [ { "edgeCloudZoneId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91", "edgeCloudZoneName": "Zone1", "edgeCloudZoneStatus": "active", "edgeCloudProvider": "Provider1", "edgeCloudRegion": "Region1" }, { "edgeCloudZoneId": "513e4567-e89b-12d3-a456-426614174000", "edgeCloudZoneName": "Zone3", "edgeCloudZoneStatus": "inactive", "edgeCloudProvider": "Provider3", "edgeCloudRegion": "Region1" }, { "edgeCloudZoneId": "123e4567-e89b-12d3-a456-426614174000", "edgeCloudZoneName": "Zone2", "edgeCloudZoneStatus": "inactive", "edgeCloudProvider": "Provider2", "edgeCloudRegion": "Region2" } ] No newline at end of file tests/unit/controllers/test_edge_cloud_controller.py +13 −26 Changes for tests/unit/controllers/test_edge_cloud_controller.py: 13 added lines, 26 removed lines. Original line number Diff line number Diff line import json import pathlib import pytest from unittest.mock import MagicMock, patch from flask import Flask Loading @@ -6,30 +8,6 @@ from edge_cloud_management_api.controllers.edge_cloud_controller import ( ) from edge_cloud_management_api.app import get_app_instance MOCK_ZONES = [ { "edgeCloudZoneId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91", "edgeCloudZoneName": "Zone1", "edgeCloudZoneStatus": "active", "edgeCloudProvider": "Provider1", "edgeCloudRegion": "Region1", }, { "edgeCloudZoneId": "513e4567-e89b-12d3-a456-426614174000", "edgeCloudZoneName": "Zone3", "edgeCloudZoneStatus": "inactive", "edgeCloudProvider": "Provider3", "edgeCloudRegion": "Region1", }, { "edgeCloudZoneId": "123e4567-e89b-12d3-a456-426614174000", "edgeCloudZoneName": "Zone2", "edgeCloudZoneStatus": "inactive", "edgeCloudProvider": "Provider2", "edgeCloudRegion": "Region2", }, ] @pytest.fixture def test_app(): Loading @@ -38,14 +16,23 @@ def test_app(): @pytest.fixture def mock_get_all_cloud_zones(): def mock_zones(): tests_path = pathlib.Path(__file__).resolve().parent.parent.parent with open(tests_path / "fixtures/edge-cloud-zones.json") as f: data = json.load(f) return data @pytest.fixture def mock_get_all_cloud_zones(mock_zones): with patch( "edge_cloud_management_api.controllers.edge_cloud_controller.get_all_cloud_zones", return_value=MOCK_ZONES, return_value=mock_zones, ) as mock_function: yield mock_function @pytest.mark.unit @pytest.mark.parametrize( "x_correlator, region, status, expected_response_status, expected_count", [ Loading tests/unit/managers/test_db_manager.py +2 −5 Changes for tests/unit/managers/test_db_manager.py: 2 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -5,12 +5,8 @@ import mongomock from edge_cloud_management_api.managers.db_manager import MongoManager def test_equals(): assert 1 == 1 class TestConfig: MONGO_URI = "mongodb://localhost:27017/test_db" MONGO_URI = "mongodb://test_admin:test_password@localhost:27017/test_db" @pytest.fixture Loading @@ -31,6 +27,7 @@ def mock_mongo_manager(): yield mongo_manager @pytest.mark.unit class TestMongoManager: """ Test the MongoManager class. Loading Loading
tests/fixtures/edge-cloud-zones.json 0 → 100644 +23 −0 Changes for tests/fixtures/edge-cloud-zones.json: 23 added lines, 0 removed lines. Original line number Diff line number Diff line [ { "edgeCloudZoneId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91", "edgeCloudZoneName": "Zone1", "edgeCloudZoneStatus": "active", "edgeCloudProvider": "Provider1", "edgeCloudRegion": "Region1" }, { "edgeCloudZoneId": "513e4567-e89b-12d3-a456-426614174000", "edgeCloudZoneName": "Zone3", "edgeCloudZoneStatus": "inactive", "edgeCloudProvider": "Provider3", "edgeCloudRegion": "Region1" }, { "edgeCloudZoneId": "123e4567-e89b-12d3-a456-426614174000", "edgeCloudZoneName": "Zone2", "edgeCloudZoneStatus": "inactive", "edgeCloudProvider": "Provider2", "edgeCloudRegion": "Region2" } ] No newline at end of file
tests/unit/controllers/test_edge_cloud_controller.py +13 −26 Changes for tests/unit/controllers/test_edge_cloud_controller.py: 13 added lines, 26 removed lines. Original line number Diff line number Diff line import json import pathlib import pytest from unittest.mock import MagicMock, patch from flask import Flask Loading @@ -6,30 +8,6 @@ from edge_cloud_management_api.controllers.edge_cloud_controller import ( ) from edge_cloud_management_api.app import get_app_instance MOCK_ZONES = [ { "edgeCloudZoneId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91", "edgeCloudZoneName": "Zone1", "edgeCloudZoneStatus": "active", "edgeCloudProvider": "Provider1", "edgeCloudRegion": "Region1", }, { "edgeCloudZoneId": "513e4567-e89b-12d3-a456-426614174000", "edgeCloudZoneName": "Zone3", "edgeCloudZoneStatus": "inactive", "edgeCloudProvider": "Provider3", "edgeCloudRegion": "Region1", }, { "edgeCloudZoneId": "123e4567-e89b-12d3-a456-426614174000", "edgeCloudZoneName": "Zone2", "edgeCloudZoneStatus": "inactive", "edgeCloudProvider": "Provider2", "edgeCloudRegion": "Region2", }, ] @pytest.fixture def test_app(): Loading @@ -38,14 +16,23 @@ def test_app(): @pytest.fixture def mock_get_all_cloud_zones(): def mock_zones(): tests_path = pathlib.Path(__file__).resolve().parent.parent.parent with open(tests_path / "fixtures/edge-cloud-zones.json") as f: data = json.load(f) return data @pytest.fixture def mock_get_all_cloud_zones(mock_zones): with patch( "edge_cloud_management_api.controllers.edge_cloud_controller.get_all_cloud_zones", return_value=MOCK_ZONES, return_value=mock_zones, ) as mock_function: yield mock_function @pytest.mark.unit @pytest.mark.parametrize( "x_correlator, region, status, expected_response_status, expected_count", [ Loading
tests/unit/managers/test_db_manager.py +2 −5 Changes for tests/unit/managers/test_db_manager.py: 2 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -5,12 +5,8 @@ import mongomock from edge_cloud_management_api.managers.db_manager import MongoManager def test_equals(): assert 1 == 1 class TestConfig: MONGO_URI = "mongodb://localhost:27017/test_db" MONGO_URI = "mongodb://test_admin:test_password@localhost:27017/test_db" @pytest.fixture Loading @@ -31,6 +27,7 @@ def mock_mongo_manager(): yield mongo_manager @pytest.mark.unit class TestMongoManager: """ Test the MongoManager class. Loading