コード例 #1
0
def text_get_all_complexes(mock_send):
    """Test get_all Complex class method."""
    mock_send.return_value = {}
    assert len(list(Complex.get_all())) == 0

    mock_send.return_value = COMPLEXES
    assert len(list(Complex.get_all())) == 2
コード例 #2
0
def test_complex_get_all():
    requests.get(f"{Complex.base_url}/reset")
    complexes = list(Complex.get_all())
    assert len(complexes) == 0

    cmplx: Complex = Complex.create(
        name="test_complex", physical_location_id="test_physical_location_id")
    assert cmplx.name == "test_complex"
    assert cmplx.physical_location_id == "test_physical_location_id"

    complexes = list(Complex.get_all())
    assert len(complexes) == 1

    cmplx = complexes[0]
    assert cmplx.name == "test_complex"
    assert cmplx.physical_location_id == "test_physical_location_id"
コード例 #3
0
def test_complex_get_all(mock_send_message_json):
    mock_send_message_json.return_value = COMPLEXES
    complexes = list(Complex.get_all())
    assert len(complexes) == 1
    cmplx = complexes[0]
    assert cmplx.name == "integration_test_complex"
    assert cmplx.physical_location_id == "integration_test_complex"
コード例 #4
0
ファイル: create_k8s_region.py プロジェクト: rajewluk/demo
logger = logging.getLogger("")
logger.setLevel(logging.DEBUG)
fh = logging.StreamHandler()
fh_formatter = logging.Formatter(
    '%(asctime)s %(levelname)s %(lineno)d:%(filename)s(%(process)d) - %(message)s'
)
fh.setFormatter(fh_formatter)
logger.addHandler(fh)

MYPATH = os.path.dirname(os.path.realpath(__file__))

#### Create complex if not exists ####
logger.info("******** Complex *******")
try:
    complex = list(Complex.get_all(physical_location_id=Config.COMPLEX_ID))[0]
    logger.info("Complex exists")
except IndexError:
    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 *******")