'Test reading Config via an API Hook'

def test_config_hook(self):

    url = u'/v1/apps'
    response = self.client.post(url, HTTP_AUTHORIZATION=u'token    {}'.format(self.token))
    self.assertEqual(response.status_code, 201)
    app_id = response.data[u'id']
    url = u'/v1/apps/{app_id}/config'.format(**locals())
    response = self.client.get(url, HTTP_AUTHORIZATION=u'token    {}'.format(self.token))
    self.assertEqual(response.status_code, 200)
    self.assertIn(u'values', response.data)
    values = response.data[u'values']
    config = {u'username': u'autotest', u'app': app_id}
    url = u'/v1/hooks/config'.format(**locals())
    body = {u'receive_user': u'autotest', u'receive_repo': app_id}
    response = self.client.post(url, json.dumps(body), content_type=u'application/json')
    self.assertEqual(response.status_code, 401)
    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.assertIn(u'values', response.data)
    self.assertEqual(values, response.data[u'values'])
