Commit e7333364 authored by Adrian Pino's avatar Adrian Pino
Browse files

Move individual unit tests to /old.

parent 1c44e4c7
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -3,7 +3,8 @@ import pytest

from src.edgecloud.clients.aeros.client import EdgeApplicationManager as AerosClient
from src.edgecloud.clients.i2edge.client import EdgeApplicationManager as I2EdgeClient
from src.edgecloud.clients.piedge.client import EdgeApplicationManager as PiEdgeClient

# from src.edgecloud.clients.piedge.client import EdgeApplicationManager as PiEdgeClient
from src.edgecloud.core.edgecloud_factory import EdgeCloudFactory
from tests.edgecloud.test_cases import test_cases

@@ -16,7 +17,7 @@ def test_factory_edgecloud(client_name, base_url):
    client_class_map = {
        "i2edge": I2EdgeClient,
        "aeros": AerosClient,
        "piedge": PiEdgeClient,
        # "piedge": PiEdgeClient,
    }
    expected_client_class = client_class_map[client_name]
    edgecloud_platform = EdgeCloudFactory.create_edgecloud_client(client_name, base_url)
+2 −2
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ from src.edgecloud.clients.errors import EdgeCloudPlatformError
from src.edgecloud.core.edgecloud_factory import EdgeCloudFactory
from tests.edgecloud.test_cases import test_cases

zone_id = "Omega"
zone_id = "Omega12345"


@pytest.mark.parametrize("client_name, base_url", test_cases)
@@ -25,7 +25,7 @@ def test_get_edge_cloud_zones(client_name, base_url):


@pytest.mark.parametrize("client_name, base_url", test_cases)
def test_get_edge_cloud_zones_details(client_name, base_url, zone_id="Omega"):
def test_get_edge_cloud_zones_details(client_name, base_url, zone_id=zone_id):
    """
    Test that get_edge_cloud_zone_details returns valid responses for each client.
    Since each client has different response formats, we only verify basic success criteria.
+44 −30
Original line number Diff line number Diff line
@@ -3,16 +3,15 @@ import pytest

from src.edgecloud.clients.errors import EdgeCloudPlatformError
from src.edgecloud.core.edgecloud_factory import EdgeCloudFactory
from tests.edgecloud.test_cases import test_cases

# Note: artifact mgmt is only supported by i2Edge

test_cases = [
    ("i2edge", "http://192.168.123.237:30769/"),
]

artefact_id = "hello-world-from-sdk-2"
artefact_name = "hello-word-2"
repo_name = "dummy-repo-2"
artefact_id = "i2edgechart-id"
artefact_name = "i2edgechart"
repo_name = "github-cesar"
repo_type = "PUBLICREPO"
repo_url = "https://cesarcajas.github.io/helm-charts-examples/"


@pytest.mark.parametrize("client_name, base_url", test_cases)
@@ -26,8 +25,8 @@ def test_create_artefact_success(client_name, base_url):
                artefact_id=artefact_id,
                artefact_name=artefact_name,
                repo_name=repo_name,
                repo_type="PUBLICREPO",
                repo_url="https://helm.github.io/examples",
                repo_type=repo_type,
                repo_url=repo_url,
                password=None,
                token=None,
                user_name=None,
@@ -57,7 +56,10 @@ def test_create_artefact_failure(client_name, base_url):

@pytest.mark.parametrize("client_name, base_url", test_cases)
def test_get_artefact_success(client_name, base_url):
    edgecloud_platform = EdgeCloudFactory.create_edgecloud_client(client_name, base_url)
    if client_name == "i2edge":
        edgecloud_platform = EdgeCloudFactory.create_edgecloud_client(
            client_name, base_url
        )
        try:
            edgecloud_platform._get_artefact(artefact_id=artefact_id)
        except EdgeCloudPlatformError as e:
@@ -66,14 +68,20 @@ def test_get_artefact_success(client_name, base_url):

@pytest.mark.parametrize("client_name, base_url", test_cases)
def test_get_artefact_failure(client_name, base_url):
    edgecloud_platform = EdgeCloudFactory.create_edgecloud_client(client_name, base_url)
    if client_name == "i2edge":
        edgecloud_platform = EdgeCloudFactory.create_edgecloud_client(
            client_name, base_url
        )
        with pytest.raises(EdgeCloudPlatformError):
            edgecloud_platform._get_artefact(artefact_id="non-existent-artefact")


@pytest.mark.parametrize("client_name, base_url", test_cases)
def test_get_all_artefacts_success(client_name, base_url):
    edgecloud_platform = EdgeCloudFactory.create_edgecloud_client(client_name, base_url)
    if client_name == "i2edge":
        edgecloud_platform = EdgeCloudFactory.create_edgecloud_client(
            client_name, base_url
        )
        try:
            edgecloud_platform._get_all_artefacts()
        except EdgeCloudPlatformError as e:
@@ -82,7 +90,10 @@ def test_get_all_artefacts_success(client_name, base_url):

@pytest.mark.parametrize("client_name, base_url", test_cases)
def test_delete_artefact_success(client_name, base_url):
    edgecloud_platform = EdgeCloudFactory.create_edgecloud_client(client_name, base_url)
    if client_name == "i2edge":
        edgecloud_platform = EdgeCloudFactory.create_edgecloud_client(
            client_name, base_url
        )
        try:
            edgecloud_platform._delete_artefact(artefact_id=artefact_id)
        except EdgeCloudPlatformError as e:
@@ -91,6 +102,9 @@ def test_delete_artefact_success(client_name, base_url):

@pytest.mark.parametrize("client_name, base_url", test_cases)
def test_delete_artefact_failure(client_name, base_url):
    edgecloud_platform = EdgeCloudFactory.create_edgecloud_client(client_name, base_url)
    if client_name == "i2edge":
        edgecloud_platform = EdgeCloudFactory.create_edgecloud_client(
            client_name, base_url
        )
        with pytest.raises(EdgeCloudPlatformError):
            edgecloud_platform._delete_artefact(artefact_id="non-existent-artefact")
+2 −2
Original line number Diff line number Diff line
@@ -7,8 +7,8 @@ from tests.edgecloud.test_cases import test_cases

# CAMARA app payload (only mandatory fields)
app_manifest = {
    "appId": "test_app_from_SDK",
    "name": "my-application",
    "appId": "i2edgechart-id",
    "name": "i2edge-app-SDK",
    "version": "1.0.0",
    "appProvider": "i2CAT",
    "packageType": "CONTAINER",
+28 −30
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ from src.edgecloud.clients.errors import EdgeCloudPlatformError
from src.edgecloud.core.edgecloud_factory import EdgeCloudFactory
from tests.edgecloud.test_cases import test_cases

# As a pre-requirement for this test, the app should be already onboarded
appId = "i2edgechart-id"
app_zones = [
    {
@@ -20,32 +21,31 @@ app_zones = [
    }
]

# TODO: Revise this test, something is wrong. It doesn't fail even though I specify a non-existent av zone

@pytest.fixture(scope="module")  # or "session" depending on your needs
def deployed_app(request):
    client_name, base_url = request.param
    edgecloud_platform = EdgeCloudFactory.create_edgecloud_client(client_name, base_url)

    try:
        output = edgecloud_platform.deploy_app(appId, app_zones)
        return {
            "client_name": client_name,
            "base_url": base_url,
            "appInstanceId": output["deploy_name"],
        }
    except EdgeCloudPlatformError as e:
        pytest.fail(f"App deployment failed unexpectedly: {e}")
# @pytest.fixture(scope="module")
# def deployed_app(request):
#     client_name, base_url = request.param
#     edgecloud_platform = EdgeCloudFactory.create_edgecloud_client(client_name, base_url)
#     try:
#         output = edgecloud_platform.deploy_app(appId, app_zones)
#         return {
#             "client_name": client_name,
#             "base_url": base_url,
#             "appInstanceId": output["deploy_name"],
#         }
#     except EdgeCloudPlatformError as e:
#         pytest.fail(f"App deployment failed unexpectedly: {e}")


@pytest.mark.parametrize("deployed_app", test_cases, indirect=True)
def test_deploy_app_success(deployed_app):
    assert "appInstanceId" in deployed_app
    assert deployed_app["appInstanceId"].startswith("i2edgechart")  # simple check
# @pytest.mark.parametrize("deployed_app", test_cases, indirect=True)
# def test_deploy_app_success(deployed_app):
#     assert "appInstanceId" in deployed_app
#     assert deployed_app["appInstanceId"].startswith("i2edgechart")


@pytest.mark.parametrize("client_name, base_url", test_cases)
def test_get_all_apps_success(client_name, base_url):

    edgecloud_platform = EdgeCloudFactory.create_edgecloud_client(client_name, base_url)
    try:
        edgecloud_platform.get_all_deployed_apps()
@@ -56,7 +56,6 @@ def test_get_all_apps_success(client_name, base_url):

@pytest.mark.parametrize("client_name, base_url", test_cases)
def test_get_app_success(client_name, base_url):

    edgecloud_platform = EdgeCloudFactory.create_edgecloud_client(client_name, base_url)
    try:
        edgecloud_platform.get_deployed_app(
@@ -67,13 +66,12 @@ def test_get_app_success(client_name, base_url):
        pytest.fail(f"App instance retrieval failed unexpectedly: {e}")


@pytest.mark.parametrize("deployed_app", test_cases, indirect=True)
def test_undeploy_app_success(deployed_app):
    edgecloud_platform = EdgeCloudFactory.create_edgecloud_client(
        deployed_app["client_name"], deployed_app["base_url"]
    )

    try:
        edgecloud_platform.undeploy_app(deployed_app["appInstanceId"])
    except EdgeCloudPlatformError as e:
        pytest.fail(f"App undeployment failed unexpectedly: {e}")
# @pytest.mark.parametrize("deployed_app", test_cases, indirect=True)
# def test_undeploy_app_success(deployed_app):
#     edgecloud_platform = EdgeCloudFactory.create_edgecloud_client(
#         deployed_app["client_name"], deployed_app["base_url"]
#     )
#     try:
#         edgecloud_platform.undeploy_app(deployed_app["appInstanceId"])
#     except EdgeCloudPlatformError as e:
#         pytest.fail(f"App undeployment failed unexpectedly: {e}")