• Featured,  Testing,  Tutorials

    Continuous delivery with Tox and Bitbucket Pipelines

    In this post we will take a look at Continuous Delivery using Tox and Bitbucket Pipelines. We will setup a basic Django project, use Tox to automate our testing and push our project to a Bitbucket repository. Then we will enable Bitbucket Pipelines to run our automated testing when we push new code to our remote repository. Important: The Bitbucket Pipelines product is currently still in Beta. It's possible to sign up for Beta access and in my experience Atlassian will quickly get you an account. What is Continuous Delivery? When we talk about Continuous Delivery it's very easy to start looking like buzzword spewing startup hipster. Don't get me wrong,…

  • Django,  Recipes

    Permission checking in Django views

    When using the django.contrib.auth application in your project you have a number of options available for permission checking. In this recipe we will go over a number of possibilities provided by Django and offer a custom pattern you can implement. Simple testing of User objects When using function based views in your Django apps you can use the [crayon-5c130fbaad56a629458509-i/]  decorator. This is a function decorator provided by Django that you can apply to a view function. Like the decorator name says, it tests a user object. The callable you pass the decorator should take a User object and return [crayon-5c130fbaad56e304763294-i/]  when your test passes. Return [crayon-5c130fbaad56f437521783-i/]  from your callable to perform a…