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()
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
def test_create(mock_category, mock_create): svc = Service() svc.create() mock_create.assert_called_once_with("service_create.json.j2", name="ONAP-test-Service", instantiation_type="A-la-carte", category=svc.category) mock_create.reset_mock() svc = Service(instantiation_type=ServiceInstantiationType.MACRO) svc.create() mock_create.assert_called_once_with("service_create.json.j2", name="ONAP-test-Service", instantiation_type="Macro", category=svc.category)
logger.info("******** Onboard VSP *******") mypath = os.path.dirname(os.path.realpath(__file__)) myvspfile = os.path.join(mypath, Config.VSPFILE) vsp = Vsp(name=Config.VSPNAME, vendor=vendor, package=open(myvspfile, 'rb')) vsp.onboard() logger.info("******** Onboard VF *******") vf = Vf(name=Config.VFNAME) vf.vsp = vsp vf.create() vf.onboard() logger.info("******** Onboard Service *******") svc = Service(name=Config.SERVICENAME, instantiation_type=ServiceInstantiationType.MACRO) svc.create() if svc.status == const.DRAFT: svc.add_resource(vf) logger.info("******** Set SDNC properties for VF ********") component = svc.get_component(vf) prop = component.get_property("sdnc_model_version") prop.value = SDNC_MODEL_VERSION prop = component.get_property("sdnc_artifact_name") prop.value = Config.SDNC_ARTIFACT_NAME prop = component.get_property("sdnc_model_name") prop.value = SDNC_MODEL_NAME prop = component.get_property("controller_actor") prop.value = "CDS" prop = component.get_property("skip_post_instantiation_configuration")