예제 #1
0
def test_service_instance_deletion(mock_sdc_service,
                                   mock_service_deletion_request):
    service_instance = ServiceInstance(service_subscription=mock.MagicMock(),
                                       instance_id="test_service_instance_id")
    service_instance.delete()
    mock_service_deletion_request.assert_called_once_with(
        service_instance, True)
예제 #2
0
def test_service_instance_vnf_instances(mock_relationships_send_message_json):
    service_instance = ServiceInstance(service_subscription=mock.MagicMock(),
                                       instance_id="test_service_instance_id")
    mock_relationships_send_message_json.return_value = {"relationship": []}
    assert len(list(service_instance.vnf_instances)) == 0
    mock_relationships_send_message_json.return_value = RELATIONSHIPS
    assert len(list(service_instance.vnf_instances)) == 1
def test_service_instance():
    service_subscription = mock.MagicMock()
    service_subscription.url = "test_url"
    service_instance = ServiceInstance(service_subscription=service_subscription,
                                       instance_id="test_service_instance_id")
    assert service_instance.url == (f"{service_instance.service_subscription.url}/service-instances/"
                                    f"service-instance/{service_instance.instance_id}")
예제 #4
0
def test_service_instance_sdc_service(mock_service_get_by_unique_uuid):
    si = ServiceInstance(service_subscription=mock.MagicMock(),
                         instance_id="test_service_instance_id",
                         model_invariant_id="1234")
    si.sdc_service
    mock_service_get_by_unique_uuid.assert_called_once_with("1234")
    si.sdc_service
    mock_service_get_by_unique_uuid.assert_called_once_with("1234")
예제 #5
0
def test_service_instance_network_instances(
        mock_aai_element_send_message_json):
    service_instance = ServiceInstance(service_subscription=mock.MagicMock(),
                                       instance_id="test_service_instance_id")
    mock_aai_element_send_message_json.side_effect = [
        RELATIONSHIPS_NETWORK, NETWORK_INSTANCE
    ]
    assert len(list(service_instance.network_instances)) == 1
예제 #6
0
def test_service_instance_add_vnf(mock_vnf_instantiation):
    service_instance = ServiceInstance(service_subscription=mock.MagicMock(),
                                       instance_id="test_service_instance_id")
    service_instance.orchestration_status = "Inactive"
    with pytest.raises(AttributeError):
        service_instance.add_vnf(mock.MagicMock(), mock.MagicMock(),
                                 mock.MagicMock())
    service_instance.orchestration_status = "Active"
    service_instance.add_vnf(mock.MagicMock(), mock.MagicMock(),
                             mock.MagicMock())
    mock_vnf_instantiation.assert_called_once()
예제 #7
0
def test_service_instance_add_vnf(mock_sdc_service, mock_vnf_instantiation):
    service_instance = ServiceInstance(service_subscription=mock.MagicMock(),
                                       instance_id="test_service_instance_id")
    service_instance.orchestration_status = "Inactive"
    with pytest.raises(StatusError) as exc:
        service_instance.add_vnf(mock.MagicMock(), mock.MagicMock(),
                                 mock.MagicMock())
    assert exc.type == StatusError
    service_instance.orchestration_status = "Active"
    service_instance.add_vnf(mock.MagicMock(), mock.MagicMock(),
                             mock.MagicMock())
    mock_vnf_instantiation.assert_called_once()
예제 #8
0
def test_get_service_instance_by_id(mock_get):
    """Test Service Subscription get_service_instance_by_id method"""
    service_subscription = ServiceSubscription(
        customer=None,
        service_type="test_service_type",
        resource_version="test_resource_version")
    mock_get.return_value = ServiceInstance(
        service_subscription="ServiceSubscription",
        instance_id="5410bf79-2aa3-450e-a324-ec5630dc18cf")
    service_instance = service_subscription.get_service_instance_by_id(
        service_instance_id="5410bf79-2aa3-450e-a324-ec5630dc18cf")
    assert service_instance.instance_id == "5410bf79-2aa3-450e-a324-ec5630dc18cf"
예제 #9
0
def test_vnf_instance(mock_vnf_deletion_request):
    service_instance = ServiceInstance(None,
                                       instance_id="test_service_instance_id")
    vnf_instance = VnfInstance(service_instance,
                               vnf_id="test_vnf_id",
                               vnf_type="test_vnf_type",
                               in_maint=False,
                               is_closed_loop_disabled=True)
    assert vnf_instance.service_instance == service_instance
    assert vnf_instance.vnf_id == "test_vnf_id"
    assert vnf_instance.vnf_type == "test_vnf_type"
    assert vnf_instance.in_maint is False
    assert vnf_instance.is_closed_loop_disabled is True
    assert vnf_instance._vnf is None
    assert vnf_instance.url == (
        f"{vnf_instance.base_url}{vnf_instance.api_version}/network/"
        f"generic-vnfs/generic-vnf/{vnf_instance.vnf_id}")
    vnf_instance.delete()
    mock_vnf_deletion_request.assert_called_once_with(vnf_instance)
def test_service_instance_count(mock_send_message_json):
    mock_send_message_json.return_value = COUNT
    assert ServiceInstance.count(service_subscription=mock.MagicMock())