diff --git a/example/list_invoices.py b/example/list_invoices.py deleted file mode 100644 index b864674..0000000 --- a/example/list_invoices.py +++ /dev/null @@ -1 +0,0 @@ -from myfinances import MyFinancesClient diff --git a/myfinances/__pycache__/models.cpython-312.pyc b/myfinances/__pycache__/models.cpython-312.pyc index 52c504a..b3bd3ca 100644 Binary files a/myfinances/__pycache__/models.cpython-312.pyc and b/myfinances/__pycache__/models.cpython-312.pyc differ diff --git a/myfinances/clients/__pycache__/service.cpython-312.pyc b/myfinances/clients/__pycache__/service.cpython-312.pyc index 67b6243..781aea2 100644 Binary files a/myfinances/clients/__pycache__/service.cpython-312.pyc and b/myfinances/clients/__pycache__/service.cpython-312.pyc differ diff --git a/myfinances/clients/service.py b/myfinances/clients/service.py index de2e1de..51b9dab 100644 --- a/myfinances/clients/service.py +++ b/myfinances/clients/service.py @@ -53,6 +53,16 @@ def create_client( return MyFinancesResponse(**response.dict()) def get_client(self, client_id: int) -> MyFinancesResponse[Client]: + """ + Retrieving a singular client via their client_id. + + Args: + client_id (int): The ID of the client to retrieve. + + Returns: + MyFinancesResponse[Client]: Data of the client's details. + + """ response = self._client._get(f"/clients/{client_id}") return MyFinancesResponse(**response.dict()) @@ -62,38 +72,23 @@ def update_client(self, email: Optional[EmailStr] = None, company: Optional[str] = None, contact_method: Optional[str] = None, - is_representative: bool = None, + is_representative: Optional[bool] = None, address: Optional[str] = None, city: Optional[str] = None, country: Optional[str] = None) -> MyFinancesResponse[Client]: - params = {} - - if name is not None: - params["name"] = name - - if phone_number is not None: - params["phone_number"] = phone_number - - if email is not None: - params["email"] = email - - if company is not None: - params["company"] = company - - if contact_method is not None: - params["contact_method"] = contact_method - - if is_representative is not None: - params["is_representative"] = is_representative - - if address is not None: - params["address"] = address - - if city is not None: - params["city"] = city - - if country is not None: - params["country"] = country + params = { + key: value for key, value in{ + "name": name, + "phone_number": phone_number, + "email": email, + "company": company, + "contact_method": contact_method, + "is_representative": is_representative, + "address": address, + "city": city, + "country": country, + }.items() if value is not None + } response = self._client._patch("/clients/update/", json=params) return MyFinancesResponse(**response.dict()) diff --git a/myfinances/models.py b/myfinances/models.py index 8a2a22a..bd7ea07 100644 --- a/myfinances/models.py +++ b/myfinances/models.py @@ -9,7 +9,6 @@ class Meta(BaseModel): success: bool status_code: int - message: str content: dict = None diff --git a/tests/__pycache__/test_clients.cpython-312-pytest-8.3.3.pyc b/tests/__pycache__/test_clients.cpython-312-pytest-8.3.3.pyc index 76878b8..938178b 100644 Binary files a/tests/__pycache__/test_clients.cpython-312-pytest-8.3.3.pyc and b/tests/__pycache__/test_clients.cpython-312-pytest-8.3.3.pyc differ diff --git a/tests/__pycache__/test_finance.cpython-312-pytest-8.3.3.pyc b/tests/__pycache__/test_finance.cpython-312-pytest-8.3.3.pyc index 769f922..6021d20 100644 Binary files a/tests/__pycache__/test_finance.cpython-312-pytest-8.3.3.pyc and b/tests/__pycache__/test_finance.cpython-312-pytest-8.3.3.pyc differ diff --git a/tests/__pycache__/test_receipts.cpython-312-pytest-8.3.3.pyc b/tests/__pycache__/test_receipts.cpython-312-pytest-8.3.3.pyc index 0882008..35f9fc8 100644 Binary files a/tests/__pycache__/test_receipts.cpython-312-pytest-8.3.3.pyc and b/tests/__pycache__/test_receipts.cpython-312-pytest-8.3.3.pyc differ diff --git a/tests/test_clients.py b/tests/test_clients.py index 6144557..d06ae5f 100644 --- a/tests/test_clients.py +++ b/tests/test_clients.py @@ -34,7 +34,6 @@ def test_create_client(clients_service, mock_client): "meta": { "success": True, "status_code": 200, - "message": "Success" }, "data": {"client_id": 123} } @@ -45,11 +44,10 @@ def test_create_client(clients_service, mock_client): response = clients_service.create_client(**clients_data) - mock_client._post.assert_called_once_with("/clients/create/", clients_data) + mock_client._post.assert_called_once_with("/clients/create/", json=clients_data) assert response.data["client_id"] == 123 assert response.meta.success is True assert response.meta.status_code == 200 - assert response.meta.message == "Success" def test_list_clients(clients_service, mock_client): @@ -66,7 +64,6 @@ def test_list_clients(clients_service, mock_client): "meta": { "success": True, "status_code": 200, - "message": "Success" }, "data": clients_data } @@ -80,7 +77,6 @@ def test_list_clients(clients_service, mock_client): mock_client._get.assert_called_once_with("/clients/", params={}) assert response.meta.success is True assert response.meta.status_code == 200 - assert response.meta.message == "Success" assert isinstance(response.data, list) assert len(response.data) == 2 @@ -105,7 +101,6 @@ def test_client_by_id(clients_service, mock_client): "meta": { "success": True, "status_code": 200, - "message": "Success" }, "data": clients_data } @@ -120,7 +115,6 @@ def test_client_by_id(clients_service, mock_client): mock_client._get.assert_called_once_with(f"/clients/{clients_id}") assert response.meta.success is True assert response.meta.status_code == 200 - assert response.meta.message == "Success" assert response.data["id"] == clients_data["id"] assert response.data["name"] == clients_data["name"] @@ -142,7 +136,6 @@ def test_delete_clients(clients_service, mock_client): "meta": { "success": True, "status_code": 200, - "message": "Success" }, "data": clients_data } @@ -157,7 +150,6 @@ def test_delete_clients(clients_service, mock_client): mock_client._delete.assert_called_once_with(f"/clients/{Client_Id}/delete") assert response.meta.success is True assert response.meta.status_code == 200 - assert response.meta.message == "Success" remaining_clients = [clients for clients in clients_data if clients["id"] == Client_Id] assert len(remaining_clients) == 1 @@ -182,7 +174,6 @@ def test_update_clients_name(clients_service, mock_client): "meta": { "success": True, "status_code": 200, - "message": "Success" }, "data": clients_data } @@ -197,7 +188,6 @@ def test_update_clients_name(clients_service, mock_client): mock_client._patch.assert_called_once_with(f"/clients/update/", json={"name": new_name}) assert response.meta.success is True assert response.meta.status_code == 200 - assert response.meta.message == "Success" # Updated Version updated_clients_data = { @@ -217,7 +207,6 @@ def test_update_clients_name(clients_service, mock_client): "meta": { "success": True, "status_code": 200, - "message": "Success" }, "data": updated_clients_data } diff --git a/tests/test_finance.py b/tests/test_finance.py index da93122..da9137c 100644 --- a/tests/test_finance.py +++ b/tests/test_finance.py @@ -27,7 +27,6 @@ def test_create_invoice(invoices_service, mock_client): "meta": { "success": True, "status_code": 200, - "message": "Successfully created" }, "data": { "invoice_id": 102, @@ -44,7 +43,6 @@ def test_create_invoice(invoices_service, mock_client): assert response.data["invoice_id"] == 102 assert response.meta.success is True assert response.meta.status_code == 200 - assert response.meta.message == "Successfully created" def test_list_invoices(invoices_service, mock_client): @@ -58,7 +56,6 @@ def test_list_invoices(invoices_service, mock_client): "meta": { "success": True, "status_code": 200, - "message": "Successfully fetched invoices" }, "data": invoice_list } @@ -73,7 +70,6 @@ def test_list_invoices(invoices_service, mock_client): assert response.meta.success is True assert response.meta.status_code == 200 - assert response.meta.message == "Successfully fetched invoices" assert isinstance(response.data, list) assert len(response.data) == 2 @@ -93,7 +89,6 @@ def test_delete_invoice(invoices_service, mock_client): "meta": { "success": True, "status_code": 200, - "message": "Successfully deleted invoice" }, "data": invoice_list } @@ -111,7 +106,6 @@ def test_delete_invoice(invoices_service, mock_client): assert response.meta.success is True assert response.meta.status_code == 200 - assert response.meta.message == "Successfully deleted invoice" remaining_invoices = [invoice for invoice in invoice_list if invoice['id'] != invoice_id] @@ -132,7 +126,6 @@ def test_get_invoice(invoices_service, mock_client): "meta": { "success": True, "status_code": 200, - "message": "Successfully deleted invoice" }, "data": invoice_data } @@ -148,7 +141,6 @@ def test_get_invoice(invoices_service, mock_client): assert response.meta.success is True assert response.meta.status_code == 200 - assert response.meta.message == "Successfully deleted invoice" assert response.data["id"] == invoice_data["id"] assert response.data["customer_id"] == invoice_data["customer_id"] @@ -167,7 +159,6 @@ def test_search_invoices_by_id(invoices_service, mock_client): "meta": { "success": True, "status_code": 200, - "message": "Invoices fetched successfully" }, "data": invoice_data } @@ -183,7 +174,6 @@ def test_search_invoices_by_id(invoices_service, mock_client): assert response.meta.success is True assert response.meta.status_code == 200 - assert response.meta.message == "Invoices fetched successfully" assert response.data[1]["id"] == 2 assert response.data[1]["customer_id"] == 124 @@ -203,7 +193,6 @@ def test_update_invoice(invoices_service, mock_client): "meta": { "success": True, "status_code": 200, - "message": "Invoices successfully updated" }, "data": invoice_data } @@ -220,7 +209,6 @@ def test_update_invoice(invoices_service, mock_client): assert response.meta.success is True assert response.meta.status_code == 200 - assert response.meta.message == "Invoices successfully updated" # updated version updated_invoice_data = { @@ -236,7 +224,6 @@ def test_update_invoice(invoices_service, mock_client): "meta": { "success": True, "status_code": 200, - "message": "Invoice fetched successfully" }, "data": updated_invoice_data } diff --git a/tests/test_receipts.py b/tests/test_receipts.py index 75b9a0f..d34af13 100644 --- a/tests/test_receipts.py +++ b/tests/test_receipts.py @@ -3,6 +3,7 @@ from myfinances import MyFinancesClient from myfinances.finance.receipts.service import ReceiptService + @pytest.fixture def mock_client(): mock = Mock(spec=MyFinancesClient) @@ -30,7 +31,6 @@ def test_create_receipt(receipts_service, mock_client): "meta": { "success": True, "status_code": 200, - "message": "Success" }, "data": receipts_data } @@ -44,7 +44,6 @@ def test_create_receipt(receipts_service, mock_client): mock_client._post.assert_called_once_with("/receipts/create/", json=receipts_data) assert response.meta.success is True assert response.meta.status_code == 200 - assert response.meta.message == "Success" assert response.data["name"] == receipts_data["name"] assert response.data["image"] == receipts_data["image"] @@ -62,7 +61,6 @@ def test_list_receipts(receipts_service, mock_client): "meta": { "success": True, "status_code": 200, - "message": "Success" }, "data": list_of_receipts } @@ -71,12 +69,10 @@ def test_list_receipts(receipts_service, mock_client): mock_response.dict.return_value = mock_response_data mock_client._get.return_value = mock_response - response = receipts_service.list_receipts() mock_client._get.assert_called_once_with("/receipts/") assert response.meta.success is True assert response.meta.status_code == 200 - assert response.meta.message == "Success" assert isinstance(response.data, list) assert len(response.data) == 2 @@ -94,7 +90,6 @@ def test_delete_receipt(receipts_service, mock_client): "meta": { "success": True, "status_code": 200, - "message": "Successfully deleted invoice" }, "data": list_of_receipts } @@ -112,7 +107,6 @@ def test_delete_receipt(receipts_service, mock_client): assert response.meta.success is True assert response.meta.status_code == 200 - assert response.meta.message == "Successfully deleted invoice" remaining_receipts = [receipt for receipt in list_of_receipts if receipt["id"] != receipt_id] assert len(remaining_receipts) == 1 @@ -131,7 +125,6 @@ def test_update_receipt(receipts_service, mock_client): "meta": { "success": True, "status_code": 200, - "message": "Success" }, "data": list_of_receipts } @@ -146,6 +139,5 @@ def test_update_receipt(receipts_service, mock_client): assert response.meta.success is True assert response.meta.status_code == 200 - assert response.meta.message == "Success" assert response.data[1]["name"] == search_name