MENU

Fun & Interesting

Django & HTMX App - Custom Managers | pytest & factory-boy for unit tests

BugBytes 4,914 11 months ago
Video Not Working? Fix It Now

โ˜•๏ธ ๐—•๐˜‚๐˜† ๐—บ๐—ฒ ๐—ฎ ๐—ฐ๐—ผ๐—ณ๐—ณ๐—ฒ๐—ฒ: To support the channel and encourage new videos, please consider buying me a coffee here: https://ko-fi.com/bugbytes โญTop resource to learn Python - https://datacamp.pxf.io/kOjKkV โญ In this video, we'll add a custom model manager to our app's transaction model, and will set up pytest and factory-boy for unit testing our application functionality. Github: https://github.com/bugbytes-io/Django-HTMX-Finance-App ๐Ÿ“Œ ๐—–๐—ต๐—ฎ๐—ฝ๐˜๐—ฒ๐—ฟ๐˜€: 00:00 Intro 00:55 Creating custom Django QuerySet methods 05:40 Override default model manager in Django model 10:05 Setting up pytest 11:45 Creating factory-boy Factory classes for Django models 18:11 Testing out Factory classes 19:51 Creating pytest fixture to inject transactions 21:22 Writing pytest functions for custom QuerySet methods ๐—ฆ๐—ผ๐—ฐ๐—ถ๐—ฎ๐—น ๐— ๐—ฒ๐—ฑ๐—ถ๐—ฎ: ๐Ÿ“– Blog: https://bugbytes.io/posts/ ๐Ÿ‘พ Github: https://github.com/bugbytes-io/Django-HTMX-Finance-App ๐Ÿฆ Twitter: https://twitter.com/bugbytesio ๐Ÿ“š ๐—™๐˜‚๐—ฟ๐˜๐—ต๐—ฒ๐—ฟ ๐—ฟ๐—ฒ๐—ฎ๐—ฑ๐—ถ๐—ป๐—ด ๐—ฎ๐—ป๐—ฑ ๐—ถ๐—ป๐—ณ๐—ผ๐—ฟ๐—บ๐—ฎ๐˜๐—ถ๐—ผ๐—ป: Django Managers: https://docs.djangoproject.com/en/5.0/topics/db/managers/ Pytest: https://docs.pytest.org/en/8.2.x/ pytest-django: https://pytest-django.readthedocs.io/en/latest/ factory-boy: https://factoryboy.readthedocs.io/en/stable/ #python #django #webdevelopment #htmx

Comment