Skip to content

Commit 0ba5858

Browse files
authored
Merge pull request #13 from paywithextend/bug/final-checks
Bug/final checks
2 parents 41e0d4a + ff69c32 commit 0ba5858

File tree

3 files changed

+46
-43
lines changed

3 files changed

+46
-43
lines changed

README.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Python library for the Extend API
55
[![Python Version](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
66
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
77
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
8+
[![Documentation](https://img.shields.io/badge/docs-stoplight-blue)](https://paywithextend.stoplight.io/)
89

910
A Python client for the Extend API, providing a simple and intuitive interface for managing virtual cards, transactions,
1011
and more.
@@ -14,9 +15,11 @@ and more.
1415
- Create and manage virtual cards
1516
- Handle recurring card operations
1617
- Track transactions
17-
- Full async/await support
18-
- Type hints and validation
19-
- Comprehensive test suite
18+
- Expense management
19+
20+
## Documentation
21+
22+
For detailed API documentation, please visit our [Stoplight documentation](https://paywithextend.stoplight.io/).
2023

2124
## Installation
2225

@@ -29,7 +32,7 @@ pip install extend-python
2932
### From Source
3033

3134
```bash
32-
git clone https://github.com/yourusername/extend-python.git
35+
git clone https://github.com/paywithextend/extend-python.git
3336
cd extend-python
3437
pip install -e .
3538
```
@@ -74,7 +77,7 @@ The following environment variables are required for integration tests and examp
7477

7578
1. Clone the repository:
7679
```bash
77-
git clone https://github.com/yourusername/extend-python.git
80+
git clone https://github.com/paywithextend/extend-python.git
7881
cd extend-python
7982
```
8083

@@ -101,12 +104,6 @@ The following environment variables are required for integration tests and examp
101104
pytest tests/test_integration.py
102105
```
103106

104-
5. Format code:
105-
```bash
106-
black .
107-
isort .
108-
```
109-
110107
## Testing
111108

112109
The project includes both unit tests and integration tests:
@@ -119,20 +116,20 @@ To run integration tests, make sure you have set up the required environment var
119116

120117
## Contributing
121118

122-
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to
123-
discuss what you would like to change.
119+
We welcome contributions from the community!
124120

125121
1. Fork the repository
126122
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
127123
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
128124
4. Push to the branch (`git push origin feature/amazing-feature`)
129125
5. Open a Pull Request
130126

127+
131128
## License
132129

133130
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
134131

135132
## Acknowledgments
136133

137-
- [Extend API Documentation](https://docs.extend.com)
134+
- [Extend API Documentation](https://paywithextend.stoplight.io/)
138135
- [httpx](https://www.python-httpx.org/) for async HTTP requests

extend/config/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
elif env == "prod":
1212
from .config_prod import API_HOST, API_VERSION
1313
else:
14-
from .config_stage import API_HOST, API_VERSION
14+
from .config_prod import API_HOST, API_VERSION
1515

1616
__all__ = [
1717
"API_HOST",

tests/test_integration.py

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -402,34 +402,41 @@ class TestTransactionExpenseData:
402402
@pytest.mark.asyncio
403403
async def test_update_transaction_expense_data_with_specific_category_and_label(self, extend):
404404
"""Test updating the expense data for a transaction using a specific expense category and label."""
405-
# Retrieve available expense categories (active ones)
406-
categories_response = await extend.expense_data.get_expense_categories(active=True)
407-
assert "expenseCategories" in categories_response, "Response should include 'expenseCategories'"
408-
expense_categories = categories_response["expenseCategories"]
409-
assert expense_categories, "No expense categories available for testing"
410-
411-
# For this test, pick the first expense category
412-
category = expense_categories[0]
413-
category_id = category["id"]
414-
415-
# Retrieve the labels for the chosen expense category
416-
labels_response = await extend.expense_data.get_expense_category_labels(
417-
category_id=category_id,
418-
page=0,
419-
per_page=10
405+
# Create a new expense category for testing
406+
u = uuid.uuid4()
407+
category_name = f"Integration Test Category {u}"
408+
category_code = f"INTEG-CAT-{u}"
409+
category_resp = await extend.expense_data.create_expense_category(
410+
name=category_name,
411+
code=category_code,
412+
required=True,
413+
active=True,
414+
free_text_allowed=False,
420415
)
421-
assert "expenseLabels" in labels_response, "Response should include 'expenseLabels'"
422-
expense_labels = labels_response["expenseLabels"]
423-
assert expense_labels, "No expense labels available for the selected category"
416+
category_id = category_resp["id"]
417+
assert category_resp["name"] == category_name
418+
assert category_resp["code"] == category_code
424419

425-
# Pick the first label from the list
426-
label = expense_labels[0]
427-
label_id = label["id"]
420+
# Create a label under the category
421+
u1 = uuid.uuid4()
422+
label_name = f"Integration Label {u1}"
423+
label_code = f"INTEG-LABEL-{u1}"
424+
label_resp = await extend.expense_data.create_expense_category_label(
425+
category_id=category_id,
426+
name=label_name,
427+
code=label_code,
428+
active=True
429+
)
430+
label_id = label_resp["id"]
431+
assert label_resp["name"] == label_name
432+
assert label_resp["code"] == label_code
428433

429434
# Retrieve at least one transaction to update expense data
430435
transactions_response = await extend.transactions.get_transactions(per_page=1)
431-
assert transactions_response.get("transactions"), "No transactions available for testing expense data update"
432-
transaction = transactions_response["transactions"][0]
436+
assert "report" in transactions_response, "Response should include 'report'"
437+
assert "transactions" in transactions_response["report"], "Response should include 'transactions'"
438+
assert transactions_response["report"]["transactions"], "No transactions available for testing expense data update"
439+
transaction = transactions_response["report"]["transactions"][0]
433440
transaction_id = transaction["id"]
434441

435442
# Prepare the expense data payload with the specific category and label
@@ -447,11 +454,10 @@ async def test_update_transaction_expense_data_with_specific_category_and_label(
447454

448455
# Verify the response contains the transaction id and expected expense details
449456
assert "id" in response, "Response should include the transaction id"
450-
if "expenseDetails" in response:
451-
# Depending on the API response, the structure might vary; adjust assertions accordingly
452-
assert response["expenseDetails"] == update_payload["expenseDetails"], (
453-
"Expense details in the response should match the update payload"
454-
)
457+
assert "expenseDetails" in response, "Response should include expenseDetails"
458+
assert len(response["expenseDetails"]) == 1, "Response should contain exactly one expense detail"
459+
assert response["expenseDetails"][0]["categoryId"] == category_id, "Category ID should match"
460+
assert response["expenseDetails"][0]["labelId"] == label_id, "Label ID should match"
455461

456462

457463
@pytest.mark.integration

0 commit comments

Comments
 (0)