'Administrator should be able to create build hooks on non-admin apps.'

def test_admin_can_hook(self):

    u'Test    creating    a    Push    via    the    API'
    user = User.objects.get(username=u'autotest2')
    token = Token.objects.get(user=user).key
    url = u'/v1/apps'
    response = self.client.post(url, HTTP_AUTHORIZATION=u'token    {}'.format(token))
    self.assertEqual(response.status_code, 201)
    app_id = response.data[u'id']
    DOCKERFILE = u'\n                                FROM    busybox\n                                CMD    /bin/true\n                                '
    body = {u'receive_user': u'autotest', u'receive_repo': app_id, u'image': u'{app_id}:v2'.format(**locals()), u'sha': u'ecdff91c57a0b9ab82e89634df87e293d259a3aa', u'dockerfile': DOCKERFILE}
    url = u'/v1/hooks/builds'
    response = self.client.post(url, json.dumps(body), content_type=u'application/json', HTTP_X_DEIS_BUILDER_AUTH=settings.BUILDER_KEY)
    self.assertEqual(response.status_code, 200)
    self.assertEqual(response.data[u'release'][u'version'], 2)
