'Test the text representation of a build.'

@mock.patch(u'requests.post', mock_status_ok)
def test_build_str(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}/builds'.format(**locals())
    body = {u'image': u'autotest/example'}
    response = self.client.post(url, json.dumps(body), content_type=u'application/json', HTTP_AUTHORIZATION=u'token    {}'.format(self.token))
    self.assertEqual(response.status_code, 201)
    build = Build.objects.get(uuid=response.data[u'uuid'])
    self.assertEqual(str(build), u'{}-{}'.format(response.data[u'app'], response.data[u'uuid'][:7]))
