def test_read_OK(self): with mock.patch('D365BCAPI.D365BCv1API.requests') as mocked_req: mocked_req.get.return_value.status_code = 200 r = Connect('http://test.lt/test', auth={'a': 'a'}, headers={'some headers'}) r.filter_text = "aa eq bb" respo = r.read() # execute with filter mocked_req.get.assert_called_with('http://test.lt/test', params='$filter=aa eq bb', auth={'a': 'a'}, headers={'some headers'}) respo = r.read() # execute without filter mocked_req.get.assert_called_with('http://test.lt/test', params=None, auth={'a': 'a'}, headers={'some headers'})
5. Modify description in comment line in existing order. "Modify existing line" example 6. Delete one line from existing order. "Record delete" example 7. Execute action Microsoft.NAV.shipAndInvoice on just created sales order. "Execute action" example 8. Check is invoice created and what are Total Amount and Remaining Amount in it. """ user = psw = "a" # basic authentication # customers url_customers = "http://bs17:7048/BC/api/v1.0/customers" # page 5471 custname = 'Cronus' # begin of customer name # create connection object: url, basic authentication, headers recommended by MS customers = Connect(url_customers, (user, psw), {"Accept-Language": "en-us"}) # we can only find customer by begin of name customers.filter_text = f"displayName ge '{custname}' and displayName le '{custname}Z'" # filter is: where displayName is greater or equal to Cronus and less or equal CronusZ response_list = customers.read() # read filtered customers if len(response_list) > 0: print("Read customers", response_list[0].get("displayName")) # 1st customer name if customers.except_error is not None: raise Exception(customers.except_error) if len(response_list) > 0: # customer exists custno = response_list[0].get( "number") # if customer exists then get it No. else: # create customer if not found custno = "91000" new_customer = {