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_add_resource_bad_result(mock_send, mock_load): svc = Service() svc.unique_identifier = "45" svc.identifier = "93" svc.status = const.DRAFT mock_send.return_value = {} resource = SdcResource() resource.unique_identifier = "12" resource.created = MagicMock(return_value=True) resource.version = "40" resource.name = "test" assert svc.add_resource(resource) is None mock_send.assert_called_once_with( 'POST', 'Add SdcResource to service', 'https://sdc.api.fe.simpledemo.onap.org:30207/sdc1/feProxy/rest/v1/catalog/services/45/resourceInstance', data= '{\n "name": "test",\n "componentVersion": "40",\n "posY": 100,\n "posX": 200,\n "uniqueId": "12",\n "originType": "SDCRESOURCE",\n "componentUid": "12",\n "icon": "defaulticon"\n}' )
def test_add_resource_not_draft(mock_send, mock_exists): mock_exists.return_value = False svc = Service() resource = SdcResource() svc.add_resource(resource) mock_send.assert_not_called()