mirror of
https://github.com/HackSoftware/Django-Styleguide.git
synced 2024-11-24 10:33:46 +03:00
Iterate over examples & text
This commit is contained in:
parent
75ed5a4010
commit
d381f22e05
19
README.md
19
README.md
|
@ -824,8 +824,8 @@ def item_buy(
|
||||||
payment.full_clean()
|
payment.full_clean()
|
||||||
payment.save()
|
payment.save()
|
||||||
|
|
||||||
# NOTE: We have to make sure that the objects is created
|
# Run the task once the transaction has commited,
|
||||||
# in the DB in order to use in the Celery task
|
# guaranteeing the object has been created.
|
||||||
transaction.on_commit(
|
transaction.on_commit(
|
||||||
lambda: payment_charge.delay(payment_id=payment.id)
|
lambda: payment_charge.delay(payment_id=payment.id)
|
||||||
)
|
)
|
||||||
|
@ -876,8 +876,9 @@ class ItemBuyTests(TestCase):
|
||||||
self,
|
self,
|
||||||
payment_charge_mock
|
payment_charge_mock
|
||||||
):
|
):
|
||||||
user = User.objects.create_user(username='Test User')
|
# How we prepare our tests is a topic for a different discussion
|
||||||
item = Item.objects.create(
|
user = given_a_user(username="Test user")
|
||||||
|
item = given_a_item(
|
||||||
name='Test Item',
|
name='Test Item',
|
||||||
description='Test Item description',
|
description='Test Item description',
|
||||||
price=10.15
|
price=10.15
|
||||||
|
@ -2406,7 +2407,15 @@ We try to match the structure of our modules with the structure of their respect
|
||||||
|
|
||||||
### Factories
|
### Factories
|
||||||
|
|
||||||
Factories are a great tool for generating data for your tests. If you're new to this concept, you can refer to this [blog post](https://www.hacksoft.io/blog/improve-your-tests-django-fakes-and-factories). We have [one more](https://www.hacksoft.io/blog/improve-your-tests-django-fakes-and-factories-advanced-usage) for more advanced usage and patters.
|
Factories are a great tool for generating data for your tests.
|
||||||
|
|
||||||
|
When used correctly, you can improve the overall quality of your tests.
|
||||||
|
|
||||||
|
If you are new to this concept, you can refer to the following materials:
|
||||||
|
|
||||||
|
- [Improve your Django tests with fakes and factories](https://www.hacksoft.io/blog/improve-your-tests-django-fakes-and-factories)
|
||||||
|
- [https://www.hacksoft.io/blog/improve-your-tests-django-fakes-and-factories-advanced-usage](https://www.hacksoft.io/blog/improve-your-tests-django-fakes-and-factories-advanced-usage)
|
||||||
|
- [DjangoCon 2022 | factory_boy: testing like a pro](https://www.youtube.com/watch?v=-C-XNHAJF-c)
|
||||||
|
|
||||||
## Celery
|
## Celery
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user