예제 #1
0
def test_uri_path(bigip):
    """Test Application Service URI."""
    appsvc = ApiApplicationService(
        **cfg_test
    )
    assert appsvc

    assert appsvc._uri_path(bigip) == bigip.tm.sys.application.services.service
예제 #2
0
def test_hash():
    """Test Application Service hash."""
    appsvc = ApiApplicationService(**cfg_test)
    appsvc1 = ApiApplicationService(**cfg_test)
    cfg_changed = copy(cfg_test)
    cfg_changed['name'] = 'test'
    appsvc2 = ApiApplicationService(**cfg_changed)
    cfg_changed = copy(cfg_test)
    cfg_changed['partition'] = 'other'
    appsvc3 = ApiApplicationService(**cfg_changed)
    assert appsvc
    assert appsvc1
    assert appsvc2
    assert appsvc3

    assert hash(appsvc) == hash(appsvc1)
    assert hash(appsvc) != hash(appsvc2)
    assert hash(appsvc) != hash(appsvc3)
예제 #3
0
def test_update_app_service(bigip, mock_resource):
    """Test Application Service update."""
    appsvc = ApiApplicationService(**cfg_test2)
    assert appsvc

    # verify all cfg items
    expected = cfg_test2_expected

    assert appsvc.name == expected['name']
    assert appsvc.partition == expected['partition']
    assert appsvc.data['template'] == expected['template']
    assert all(v in appsvc.data['variables'] for v in expected['variables'])
    assert all(t in appsvc.data['tables'] for t in expected['tables'])

    appsvc.update(bigip)

    # verify that 'update' was called with expected dict
    assert Resource.update.called
예제 #4
0
def test_update_app_service(bigip, mock_resource):
    """Test Application Service update."""
    appsvc = ApiApplicationService(
        **cfg_test2
    )
    assert appsvc

    # verify all cfg items
    expected = cfg_test2_expected

    assert appsvc.name == expected['name']
    assert appsvc.partition == expected['partition']
    assert appsvc.data['template'] == expected['template']
    assert all(v in appsvc.data['variables'] for v in expected['variables'])
    assert all(t in appsvc.data['tables'] for t in expected['tables'])

    appsvc.update(bigip)

    # verify that 'update' was called with expected dict
    assert Resource.update.called
예제 #5
0
def test_eq():
    """Test Application Service equality."""
    partition = 'Common'
    name = 'app_svc'

    appsvc1 = ApiApplicationService(**cfg_test)
    appsvc2 = ApiApplicationService(**cfg_test)
    cfg_test3 = deepcopy(cfg_test)
    cfg_test3['variables']['net__client_mode'] = 'changed'
    appsvc3 = ApiApplicationService(**cfg_test3)
    pool = Pool(name=name, partition=partition)
    assert appsvc1
    assert appsvc2
    assert appsvc3
    assert appsvc1 == appsvc2

    # not equal
    assert appsvc1 != appsvc3

    # different objects
    assert appsvc1 != pool
예제 #6
0
def test_uri_path(bigip):
    """Test Application Service URI."""
    appsvc = ApiApplicationService(**cfg_test)
    assert appsvc

    assert appsvc._uri_path(bigip) == bigip.tm.sys.application.services.service