def test_validate_not_Draft(mock_send, mock_status, status): """Do nothing if not created.""" vsp = Vsp() vsp._status = status vsp.validate() mock_send.assert_not_called()
def test_equality_not_equals_not_same_object(): """Check a vsp and something different are not equals.""" vsp_1 = Vsp(name="equal") vsp_1.identifier = "1234" vsp_2 = Vendor(name="equal") assert vsp_1 != vsp_2
def test_commit_not_Validated(mock_send, mock_status, status): """Do nothing if not created.""" vsp = Vsp() vsp._status = status vsp.commit() mock_send.assert_not_called()
def test_upload_not_Draft(mock_send, mock_status, status): """Do nothing if not created.""" vsp = Vsp() vsp._status = status vsp.upload_package('data') mock_send.assert_not_called()
def test__get_vsp_details_not_created(mock_send, mock_exists): mock_exists.return_value = False vsp = Vsp() assert vsp._get_vsp_details() == {} mock_send.assert_not_called()
def test__get_vsp_details_no_version(mock_send, mock_load): vsp = Vsp() vsp.identifier = "1234" mock_send.assert_not_called() assert vsp._get_vsp_details() == {}
def test_status_no_load_no_created(mock_exists): mock_exists.return_value = False vsp = Vsp() assert vsp.status == None
tosca_meta = yaml.load(meta_file, Loader=yaml.FullLoader) SDNC_MODEL_NAME = tosca_meta.get("Template-Name") SDNC_MODEL_VERSION = tosca_meta.get("Template-Version") logger.info("*******************************") logger.info("******** SERVICE DESIGN *******") logger.info("*******************************") logger.info("******** Onboard Vendor *******") vendor = Vendor(name=Config.VENDOR) vendor.onboard() 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)
def test_vendor_created_not_details(mock_created, mock_details): mock_created.return_value = True mock_details.return_value = {} vsp = Vsp() assert vsp.vendor == None mock_details.assert_called_once()
def test_vendor_created_details(mock_created, mock_details): mock_created.return_value = True mock_details.return_value = {'vendorName': 'test'} vsp = Vsp() assert vsp.vendor.name == 'test' mock_details.assert_called_once()
def test_vendor_not_created_not_vendor(mock_created, mock_details): mock_created.return_value = False vsp = Vsp() assert vsp.vendor == None mock_details.assert_not_called()
def test_version_with_load(mock_load): vsp = Vsp() vsp.identifier = "1234" assert vsp.version == None mock_load.assert_called_once()
def test_version_no_load_created(mock_load): vsp = Vsp() vsp.identifier = "1234" vsp._version = "64" assert vsp.version == "64" mock_load.assert_not_called()
def test_create_no_vendor(mock_send, mock_exists): """Do nothing if no vendor.""" vsp = Vsp() mock_exists.return_value = False vsp.create() mock_send.assert_not_called()
def test_status_status_is_certified_in_SDC(mock_vsp_items): vsp = Vsp() vsp.identifier = "1234" mock_vsp_items.return_value = {'status': const.CERTIFIED} vsp._status = "Draft" assert vsp.status == const.CERTIFIED
def test_version_no_load_no_created(mock_load, mock_exists): mock_exists.return_value = False vsp = Vsp() assert vsp.version == None mock_load.assert_not_called()
def test__get_items_version_details_not_created(mock_send, mock_created): vsp = Vsp() mock_created.return_value = False assert vsp._get_item_version_details() == {} mock_send.assert_not_called()