uptick / pymyob

A Python SDK for the MYOB Business (formerly AccountRight Live, and New Essentials) API.
BSD 3-Clause "New" or "Revised" License
18 stars 24 forks source link

Update endpoints.py customer_payments #62

Closed HHry0918 closed 3 years ago

HHry0918 commented 3 years ago

Fixes #57

Update customer_payments method to include GET, POST and DELETE (PUT is not supported according to the documentation api)

jarekwg commented 3 years ago

Click into github checks and update them so that they're not failing. In your cloned repo, you can run python setup.py test from your root directory to see if the tests are all passing.

HHry0918 commented 3 years ago

Hi, not sure what this error is in your test

Traceback (most recent call last):
  File "c:\users\harry\documents\github\pymyob_fork\tests\test_endpoints.py", line 203, in test_customer_payments
    self.assertEqual(repr(self.companyfile.customer_payments), (
AssertionError: 'Sale[31 chars]     all() - Return all sale customer payments[199 chars]ent.' != 'Sale[31 chars]                all() - Return all sale custom[250 chars]t.\n'
  Sale_CustomerPaymentManager:
-           all() - Return all sale customer payments for an AccountRight company file.
+                      all() - Return all sale customer payment types for an AccountRight company file.
? +++++++++++                                                  +++++
-     delete(uid) - Delete selected sale customer payment.
+                delete(uid) - Delete selected sale customer payment.
? +++++++++++
+                 post(data) - Create new sale customer payment.
-        get(uid) - Return selected sale customer payment.
+                   get(uid) - Return selected sale customer payment.
? +++++++++++
-      post(data) - Create new sale customer payment.
jarekwg commented 3 years ago

Take a look at the tests in this file: https://github.com/uptick/pymyob/blob/master/tests/test_endpoints.py They need to be updated to cover the endpoints you've added. The error shows you where the test's expectation doesn't match what's getting returned.

HHry0918 commented 3 years ago

Hi, following up on the error about test_endpoints.py.

Traceback (most recent call last):
  File "e:\github\pymyob\tests\test_endpoints.py", line 211, in test_customer_payments
    self.assertEndpointReached(self.companyfile.customer_payments.delete, {'uid': UID}, 'DELETE', f'/{CID}/Sale/CustomerPayment/')
  File "E:\Program\anaconda3\envs\dimo\lib\unittest\mock.py", line 1337, in patched
    return func(*newargs, **newkeywargs)
  File "e:\github\pymyob\tests\test_endpoints.py", line 48, in assertEndpointReached
    mock_request.assert_called_once_with(
  File "E:\Program\anaconda3\envs\dimo\lib\unittest\mock.py", line 919, in assert_called_once_with
    return self.assert_called_with(*args, **kwargs)
  File "E:\Program\anaconda3\envs\dimo\lib\unittest\mock.py", line 907, in assert_called_with
    raise AssertionError(_error_message()) from cause
AssertionError: expected call not found.
Expected: request('DELETE', 'https://api.myob.com/accountright/DummyCompanyId/Sale/CustomerPayment/', headers={'Authorization': 'Bearer None', 'x-myobapi-cftoken': '!encoded-userpass=', 'x-myobapi-key': 'KeyToTheKingdom', 'x-myobapi-version': 'v2'}, params={}, timeout=None)
Actual: request('DELETE', 'https://api.myob.com/accountright/DummyCompanyId/Sale/CustomerPayment/DummyResourceUid/', timeout=None, headers={'Authorization': 'Bearer None', 'x-myobapi-cftoken': '!encoded-userpass=', 'x-myobapi-key': 'KeyToTheKingdom', 'x-myobapi-version': 'v2'}, params={})

Not sure how I can change the expected code for assertEndpointReached methods because I have followed how the test case is supposed to be setup

jarekwg commented 3 years ago

Done in #64. Thanks @HHry0918!