[PATCH 2/6] tests: Move 'create_check' to utils

Andy Doan andy.doan at linaro.org
Wed Jul 13 00:30:49 AEST 2016


On 06/30/2016 12:30 PM, Stephen Finucane wrote:
> This is also useful for the REST API tests.
>
> Signed-off-by: Stephen Finucane <stephen.finucane at intel.com>

Reviewed-by: Andy Doan <andy.doan at linaro.org>

> diff --git a/patchwork/tests/utils.py b/patchwork/tests/utils.py

> +def create_check(**kwargs):
> +    """Create 'Check' object."""
> +    values = {
> +        'patch': create_patch(),
> +        'user': create_user(),
> +        'date': dt.now(),
> +        'state': Check.STATE_SUCCESS,
> +        'target_url': 'http://example.com/',
> +        'description': '',
> +        'context': 'jenkins-ci',
> +    }
> +    values.update(**kwargs)
> +
> +    check = Check(**values)
> +    check.save()
> +
> +    return check

Its a bit of nit, but you can do that more concisely with:

     return Check.objects.create(**values)



More information about the Patchwork mailing list