示例#1
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()
示例#2
0
def test_add_artifact_to_vf(mock_send_message, mock_load, mock_add):
    """Test Service add artifact"""
    svc = Service()
    mock_add.return_value = "54321"
    result = svc.add_artifact_to_vf(vnf_name="ubuntu16test_VF 0",
                                    artifact_type="DCAE_INVENTORY_BLUEPRINT",
                                    artifact_name="clampnode.yaml",
                                    artifact="data".encode('utf-8'))
    mock_send_message.assert_called()
    method, description, url = mock_send_message.call_args[0]
    assert method == "POST"
    assert description == "Add artifact to vf"
    assert url == (
        "https://sdc.api.fe.simpledemo.onap.org:30207/sdc1/feProxy/rest/v1/catalog/services/"
        f"{svc.unique_identifier}/resourceInstance/54321/artifacts")