'After the first initial deploy, if the containers are scaled down to zero,
they should stay that way on a new release.'

@mock.patch(u'requests.post', mock_status_ok)
def test_new_build_does_not_scale_up_automatically(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', u'sha': (u'a' * 40), u'procfile': json.dumps({u'web': u'node    server.js', u'worker': u'node    worker.js'})}
    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)
    url = u'/v1/apps/{app_id}/containers/web'.format(**locals())
    response = self.client.get(url, HTTP_AUTHORIZATION=u'token    {}'.format(self.token))
    self.assertEqual(response.status_code, 200)
    self.assertEqual(len(response.data[u'results']), 1)
    url = u'/v1/apps/{app_id}/scale'.format(**locals())
    body = {u'web': 0}
    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, 204)
    url = u'/v1/apps/{app_id}/builds'.format(**locals())
    body = {u'image': u'autotest/example', u'sha': (u'a' * 40), u'procfile': json.dumps({u'web': u'node    server.js', u'worker': u'node    worker.js'})}
    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)
    url = u'/v1/apps/{app_id}/containers/web'.format(**locals())
    response = self.client.get(url, HTTP_AUTHORIZATION=u'token    {}'.format(self.token))
    self.assertEqual(response.status_code, 200)
    self.assertEqual(len(response.data[u'results']), 0)
