def test_submit_already_certified(mock_send, mock_load, mock_exists): """Do nothing if already certified.""" mock_exists.return_value = True vendor = Vendor() vendor._status = const.CERTIFIED vendor.submit() mock_send.assert_not_called()
def test_vendor_unknown(): """Integration tests for Vendor.""" response = requests.post("{}/reset".format(SDC.base_front_url)) response.raise_for_status() vendor = Vendor(name="test") vendor.create() assert vendor.created() vendor.submit() assert vendor.status == const.CERTIFIED
def test_submit_certified_OK(mock_send, mock_load, mock_exists): """Set status to CERTIFIED if submission OK.""" mock_exists.return_value = True vendor = Vendor() vendor._status = "Draft" vendor._version = "1234" vendor.identifier = "12345" mock_send.return_value = mock.Mock() expected_data = '{\n\n "action": "Submit"\n}' vendor.submit() mock_send.assert_called_once_with( "PUT", "Submit Vendor", 'https://sdc.api.fe.simpledemo.onap.org:30207/sdc1/feProxy/onboarding-api/v1.0/vendor-license-models/12345/versions/1234/actions', data=expected_data) assert vendor.status == const.CERTIFIED
def test_submit_certified_NOK(mock_send, mock_load, mock_exists): """Don't update status if submission NOK.""" mock_exists.return_value = True vendor = Vendor() vendor._identifier = "12345" mock_send.side_effect = RequestError expected_data = '{\n\n "action": "Submit"\n}' vendor._status = "Draft" vendor._version = "1234" with pytest.raises(RequestError) as err: vendor.submit() assert err.type == RequestError mock_send.assert_called_once_with( "PUT", "Submit Vendor", 'https://sdc.api.fe.simpledemo.onap.org:30207/sdc1/feProxy/onboarding-api/v1.0/vendor-license-models/12345/versions/1234/actions', data=expected_data) assert vendor._status != const.CERTIFIED
def test_submit_not_created(mock_send, mock_load, mock_exists): """Do nothing if not created.""" mock_exists.return_value = False vendor = Vendor() vendor.submit() mock_send.assert_not_called()