def test_create_OK(mock_send, mock_exists):
    """Create and update object."""
    vsp = Vsp()
    vendor = Vendor()
    vendor._identifier = "1232"
    vsp.vendor = vendor
    expected_data = '{\n  "name": "ONAP-test-VSP",\n  "description": "vendor software product",\n  "icon": "icon",\n  "category": "resourceNewCategory.generic",\n  "subCategory": "resourceNewCategory.generic.abstract",\n  "vendorName": "Generic-Vendor",\n  "vendorId": "1232",\n  "licensingData": {},\n  "onboardingMethod": "NetworkPackage"\n}'
    mock_exists.return_value = False
    mock_send.return_value = {
        'itemId': "1234",
        'version': {
            'id': "5678",
            'status': 'state_created'
        }
    }
    vsp.create()
    mock_send.assert_called_once_with(
        "POST",
        "create Vsp",
        'https://sdc.api.fe.simpledemo.onap.org:30207/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products',
        data=expected_data)
    assert vsp.created() == True
    assert vsp._status == const.DRAFT
    assert vsp.identifier == "1234"
    assert vsp.version == "5678"
def test_vendor_created_but_already_vendor(mock_created, mock_details):
    mock_created.return_value = True
    vsp = Vsp()
    vendor = Vendor()
    vsp.vendor = vendor
    assert vsp.vendor == vendor
    mock_details.assert_not_called()
Example #3
0
def test_service_upload_tca_artifact():
    """Integration tests for Service."""
    response = requests.post("{}/reset".format(SDC.base_front_url))
    response.raise_for_status()
    vendor = Vendor(name="test")
    vendor.onboard()
    vsp = Vsp(name="test",
              package=open(
                  "{}/ubuntu16.zip".format(
                      os.path.dirname(os.path.abspath(__file__))), 'rb'))
    vsp.vendor = vendor
    vsp.onboard()
    vf = Vf(name='test', vsp=vsp)
    vf.onboard()
    svc = Service(name='test')
    svc.create()
    svc.add_resource(vf)
    assert svc.status == const.DRAFT
    payload_file = open(
        "{}/tca_clampnode.yaml".format(
            os.path.dirname(os.path.abspath(__file__))), 'rb')
    data = payload_file.read()
    svc.add_artifact_to_vf(vnf_name="test",
                           artifact_type="DCAE_INVENTORY_BLUEPRINT",
                           artifact_name="tca_clampnode.yaml",
                           artifact=data)
    payload_file.close()
Example #4
0
def test_service_unknown():
    """Integration tests for Service."""
    response = requests.post("{}/reset".format(SDC.base_front_url))
    response.raise_for_status()
    vendor = Vendor(name="test")
    vendor.onboard()
    vsp = Vsp(name="test",
              package=open(
                  "{}/ubuntu16.zip".format(
                      os.path.dirname(os.path.abspath(__file__))), 'rb'))
    vsp.vendor = vendor
    vsp.onboard()
    vf = Vf(name='test', vsp=vsp)
    vf.onboard()
    svc = Service(name='test')
    assert svc.identifier is None
    assert svc.status is None
    svc.create()
    assert svc.identifier is not None
    assert svc.status == const.DRAFT
    svc.add_resource(vf)
    svc.checkin()
    assert svc.status == const.CHECKED_IN
    svc.certify()
    assert svc.status == const.CERTIFIED
    svc.distribute()
    assert svc.status == const.DISTRIBUTED
    assert svc.distributed
Example #5
0
def test_service_properties():
    """Integration test to check properties assignment for Service."""
    response = requests.post("{}/reset".format(SDC.base_front_url))
    response.raise_for_status()
    vendor = Vendor(name="test")
    vendor.onboard()
    vsp = Vsp(name="test",
              package=open(
                  "{}/ubuntu16.zip".format(
                      os.path.dirname(os.path.abspath(__file__))), 'rb'))
    vsp.vendor = vendor
    vsp.onboard()
    vf = Vf(name='test', vsp=vsp)
    vf.onboard()
    properties = [
        Property(name="test1", property_type="string", value="123"),
        Property(name="test2", property_type="integer")
    ]
    svc = Service(name='test',
                  resources=[vf],
                  properties=properties,
                  inputs=[properties[1]])
    svc.onboard()
    service_properties = list(svc.properties)
    service_inputs = list(svc.inputs)
    assert len(service_properties) == 2
    assert len(service_inputs) == 1
def test_create_already_exists(mock_send, mock_exists):
    """Do nothing if already created in SDC."""
    vsp = Vsp()
    vendor = Vendor()
    vendor._identifier = "1232"
    vsp.vendor = vendor
    mock_exists.return_value = True
    vsp.create()
    mock_send.assert_not_called()
Example #7
0
def test_vsp_onboard_unknown():
    """Integration tests for Vsp."""
    response = requests.post("{}/reset".format(Vendor.base_front_url))
    response.raise_for_status()
    vendor = Vendor(name="test")
    vendor.onboard()
    vsp = Vsp(name="test", package=open("{}/ubuntu16.zip".format(
        os.path.dirname(os.path.abspath(__file__))), 'rb'))
    vsp.vendor = vendor
    vsp.onboard()
    assert vsp.status == const.CERTIFIED
    assert vsp.csar_uuid is not None
def test_create_OK(mock_category, mock_send, mock_exists):
    """Create and update object."""
    vf = Vf()
    vsp = Vsp()
    vendor = Vendor()
    vsp._identifier = "1232"
    vf.vsp = vsp
    vsp.vendor = vendor
    vsp._csar_uuid = "1234"
    expected_data = '{\n    "artifacts": {},\n    "attributes": [],\n    "capabilities": {},\n      "categories": [\n    {\n      "normalizedName": "generic",\n      "name": "Generic",\n      "uniqueId": "resourceNewCategory.generic",\n      "subcategories": [{"empty": false, "groupings": null, "icons": ["objectStorage", "compute"], "name": "Abstract", "normalizedName": "abstract", "ownerId": null, "type": null, "uniqueId": "resourceNewCategory.generic.abstract", "version": null}],\n      "version": null,\n      "ownerId": null,\n      "empty": false,\n      "type": null,\n      "icons": null\n    }\n  ],\n    "componentInstances": [],\n    "componentInstancesAttributes": {},\n    "componentInstancesProperties": {},\n    "componentType": "RESOURCE",\n    "contactId": "cs0008",\n    \n        "csarUUID": "1234",\n        "csarVersion": "1.0",\n    \n    "deploymentArtifacts": {},\n    "description": "VF",\n    "icon": "defaulticon",\n    "name": "ONAP-test-VF",\n    "properties": [],\n    "groups": [],\n    "requirements": {},\n    "resourceType": "VF",\n    "tags": ["ONAP-test-VF"],\n    "toscaArtifacts": {},\n    "vendorName": "Generic-Vendor",\n    "vendorRelease": "1.0"\n}'
    mock_exists.return_value = False
    mock_send.return_value = {
        'resourceType': 'VF',
        'name': 'one',
        'uuid': '1234',
        'invariantUUID': '5678',
        'version': '1.0',
        'uniqueId': '91011',
        'lifecycleState': 'NOT_CERTIFIED_CHECKOUT'
    }
    rc = ResourceCategory(name="Generic")
    rc.normalized_name = "generic"
    rc.unique_id = "resourceNewCategory.generic"
    rc.subcategories = [{
        "empty": False,
        "groupings": None,
        "icons": ["objectStorage", "compute"],
        "name": "Abstract",
        "normalizedName": "abstract",
        "ownerId": None,
        "type": None,
        "uniqueId": "resourceNewCategory.generic.abstract",
        "version": None
    }]
    rc.version = None
    rc.owner_id = None
    rc.empty = False
    rc.type = None
    rc.icons = None
    mock_category.return_value = rc
    vf.create()
    mock_send.assert_called_once_with(
        "POST",
        "create Vf",
        'https://sdc.api.fe.simpledemo.onap.org:30207/sdc1/feProxy/rest/v1/catalog/resources',
        data=expected_data)
    assert vf.created()
    assert vf._status == const.DRAFT
    assert vf.identifier == "1234"
    assert vf.unique_uuid == "5678"
    assert vf.version == "1.0"
def test_create_issue_in_creation(mock_send, mock_exists):
    """Do nothing if not created but issue during creation."""
    vsp = Vsp()
    vendor = Vendor()
    vendor._identifier = "1232"
    vsp.vendor = vendor
    expected_data = '{\n  "name": "ONAP-test-VSP",\n  "description": "vendor software product",\n  "icon": "icon",\n  "category": "resourceNewCategory.generic",\n  "subCategory": "resourceNewCategory.generic.abstract",\n  "vendorName": "Generic-Vendor",\n  "vendorId": "1232",\n  "licensingData": {},\n  "onboardingMethod": "NetworkPackage"\n}'
    mock_exists.return_value = False
    mock_send.return_value = {}
    vsp.create()
    mock_send.assert_called_once_with(
        "POST",
        "create Vsp",
        'https://sdc.api.fe.simpledemo.onap.org:30207/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products',
        data=expected_data)
    assert vsp.created() == False
Example #10
0
def test_service_onboard_unknown():
    """Integration tests for Service."""
    response = requests.post("{}/reset".format(SDC.base_front_url))
    response.raise_for_status()
    vendor = Vendor(name="test")
    vendor.onboard()
    vsp = Vsp(name="test",
              package=open(
                  "{}/ubuntu16.zip".format(
                      os.path.dirname(os.path.abspath(__file__))), 'rb'))
    vsp.vendor = vendor
    vsp.onboard()
    vf = Vf(name='test', vsp=vsp)
    vf.onboard()
    svc = Service(name='test', resources=[vf])
    svc.onboard()
    assert svc.distributed
def test_create_issue_in_creation(mock_category, mock_send, mock_exists):
    # def test_create_issue_in_creation(mock_send, mock_exists):
    """Do nothing if not created but issue during creation."""
    pnf = Pnf()
    vsp = Vsp()
    vendor = Vendor()
    vsp._identifier = "1232"
    vsp.create_csar = MagicMock(return_value=True)
    vsp.vendor = vendor
    pnf.vsp = vsp
    expected_data = '{\n    "artifacts": {},\n    "attributes": [],\n    "capabilities": {},\n      "categories": [\n    {\n      "normalizedName": "generic",\n      "name": "Generic",\n      "uniqueId": "resourceNewCategory.generic",\n      "subcategories": [{"empty": false, "groupings": null, "icons": ["objectStorage", "compute"], "name": "Abstract", "normalizedName": "abstract", "ownerId": null, "type": null, "uniqueId": "resourceNewCategory.generic.abstract", "version": null}],\n      "version": null,\n      "ownerId": null,\n      "empty": false,\n      "type": null,\n      "icons": null\n    }\n  ],\n    "componentInstances": [],\n    "componentInstancesAttributes": {},\n    "componentInstancesProperties": {},\n    "componentType": "RESOURCE",\n    "contactId": "cs0008",\n    \n    "csarUUID": "None",\n    "csarVersion": "1.0",\n    "vendorName": "Generic-Vendor",\n    \n    "deploymentArtifacts": {},\n    "description": "PNF",\n    "icon": "defaulticon",\n    "name": "ONAP-test-PNF",\n    "properties": [],\n    "groups": [],\n    "requirements": {},\n    "resourceType": "PNF",\n    "tags": ["ONAP-test-PNF"],\n    "toscaArtifacts": {},\n    "vendorRelease": "1.0"\n}'
    mock_exists.return_value = False
    mock_send.side_effect = RequestError
    rc = ResourceCategory(name="Generic")
    rc.normalized_name = "generic"
    rc.unique_id = "resourceNewCategory.generic"
    rc.subcategories = [{
        "empty": False,
        "groupings": None,
        "icons": ["objectStorage", "compute"],
        "name": "Abstract",
        "normalizedName": "abstract",
        "ownerId": None,
        "type": None,
        "uniqueId": "resourceNewCategory.generic.abstract",
        "version": None
    }]
    rc.version = None
    rc.owner_id = None
    rc.empty = False
    rc.type = None
    rc.icons = None
    mock_category.return_value = rc
    with pytest.raises(RequestError) as exc:
        pnf.create()
    mock_send.assert_called_once_with(
        "POST",
        "create Pnf",
        'https://sdc.api.fe.simpledemo.onap.org:30207/sdc1/feProxy/rest/v1/catalog/resources',
        data=expected_data)
    assert not pnf.created()
Example #12
0
def test_vsp_unknown():
    """Integration tests for Vsp."""
    response = requests.post("{}/reset".format(Vendor.base_front_url))
    response.raise_for_status()
    vendor = Vendor(name="test")
    vendor.onboard()
    vsp = Vsp(name="test")
    vsp.vendor = vendor
    vsp.create()
    assert vsp.identifier is not None
    assert vsp.status == const.DRAFT
    vsp.upload_package(open("{}/ubuntu16.zip".format(
        os.path.dirname(os.path.abspath(__file__))), 'rb'))
    assert vsp.status == const.UPLOADED
    vsp.validate()
    assert vsp.status == const.VALIDATED
    vsp.commit()
    assert vsp.status == const.COMMITED
    vsp.submit()
    assert vsp.status == const.CERTIFIED
    vsp.create_csar()
    assert vsp.csar_uuid is not None
Example #13
0
def test_vf_properties():
    """Integration test to check properties assignment for Vf."""
    response = requests.post("{}/reset".format(Vendor.base_front_url))
    response.raise_for_status()
    vendor = Vendor(name="test")
    vendor.onboard()
    vsp = Vsp(name="test",
              package=open(
                  "{}/ubuntu16.zip".format(
                      os.path.dirname(os.path.abspath(__file__))), 'rb'))
    vsp.vendor = vendor
    vsp.onboard()
    prop = Property(name="test1", property_type="string", value="123")
    vf = Vf(name="test",
            vsp=vsp,
            properties=[prop,
                        Property(name="test2", property_type="integer")],
            inputs=[prop])
    vf.onboard()
    vf_properties = list(vf.properties)
    vf_inputs = list(vf.inputs)
    assert len(vf_properties) == 2
    assert len(vf_inputs) == 1
Example #14
0
def test_vf_unknown():
    """Integration tests for Vf."""
    response = requests.post("{}/reset".format(Vendor.base_front_url))
    response.raise_for_status()
    vendor = Vendor(name="test")
    vendor.onboard()
    vsp = Vsp(name="test",
              package=open(
                  "{}/ubuntu16.zip".format(
                      os.path.dirname(os.path.abspath(__file__))), 'rb'))
    vsp.vendor = vendor
    vsp.onboard()
    vf = Vf(name='test')
    vf.vsp = vsp
    vf.create()
    assert vf.identifier is not None
    assert vf.status == const.DRAFT
    assert vf.version == "0.1"
    vf.submit()
    assert vsp.status == const.CERTIFIED
    assert vf.version == "1.0"
    vf.load()
    assert vsp.status == const.CERTIFIED
    assert vf.version == "1.0"