def test_cloud_region_get_all():
    requests.get(f"{CloudRegion.base_url}/reset")
    cloud_regions = list(CloudRegion.get_all())
    assert len(cloud_regions) == 0

    with pytest.raises(ResourceNotFound):
        CloudRegion.get_by_id("test_owner", "test_cloud_region")

    cloud_region: CloudRegion = CloudRegion.create("test_owner",
                                                   "test_cloud_region",
                                                   orchestration_disabled=True,
                                                   in_maint=False)
    cloud_regions = list(CloudRegion.get_all())
    assert len(cloud_regions) == 1
    cloud_region = cloud_regions[0]
    assert cloud_region.cloud_owner == "test_owner"
    assert cloud_region.cloud_region_id == "test_cloud_region"
Пример #2
0
def test_cloud_regions(mock_send):
    """Test get cloud regions from A&AI."""
    mock_send.return_value = CLOUD_REGION
    assert len(list(CloudRegion.get_all())) == 1
    cloud_region = next(CloudRegion.get_all())
    assert cloud_region.cloud_owner == "OPNFV"
    assert cloud_region.cloud_type == "openstack"
    assert cloud_region.complex_name == "Cruguil"

    cloud_region = next(CloudRegion.get_all())
    assert cloud_region.cloud_owner == "OPNFV"
    assert cloud_region.cloud_type == "openstack"
    assert cloud_region.complex_name == "Cruguil"

    mock_send.return_value = {}
    cloud_regions = list(CloudRegion.get_all())
    assert len(cloud_regions) == 0

    with pytest.raises(StopIteration):
        cloud_region = next(CloudRegion.get_all())

    mock_send.return_value = CLOUD_REGIONS
    cloud_regions = list(CloudRegion.get_all())
    assert len(cloud_regions) == 1
Пример #3
0
    logger.info("Complex does not exists")
    complex = Complex.create(physical_location_id=Config.COMPLEX_ID,
                             name=Config.COMPLEX_ID,
                             physical_location_type="office",
                             street1="DummyStreet 1",
                             city="DummyCity",
                             postal_code="00-000",
                             country="DummyCountry",
                             region="DummyRegion")
    logger.info("Complex created")

#### Create cloud region if not exists ####
logger.info("******** Cloud Region *******")
try:
    cloud_region = list(
        CloudRegion.get_all(cloud_owner=Config.CLOUD_OWNER,
                            cloud_region_id=Config.CLOUD_REGION))[0]
    logger.info("Cloud region exists")
except IndexError:
    logger.info("Cloud region does not exists")
    cloud_region = CloudRegion.create(
        cloud_owner=Config.CLOUD_OWNER,
        cloud_region_id=Config.CLOUD_REGION,
        cloud_type="k8s",
        owner_defined_type="t1",
        cloud_region_version="1.0",
        complex_name=complex.physical_location_id,
        cloud_zone="CloudZone",
        sriov_automation="false",
        orchestration_disabled=False,
        in_maint=False)
    logger.info("Cloud region created")