'Create build and build commands'

def test_make_build_commands(self):

    client = APIClient()
    client.login(username='super', password='test')
    resp = client.post('/api/v2/build/', {'project': 1, 'version': 1, 'success': True}, format='json')
    self.assertEqual(resp.status_code, status.HTTP_201_CREATED)
    build = resp.data
    now = datetime.datetime.utcnow()
    resp = client.post('/api/v2/command/', {'build': build['id'], 'command': 'echo    test', 'description': 'foo', 'exit_code': 0, 'start_time': str((now - datetime.timedelta(seconds=5))), 'end_time': str(now)}, format='json')
    self.assertEqual(resp.status_code, status.HTTP_201_CREATED)
    resp = client.get(('/api/v2/build/%s/' % build['id']))
    self.assertEqual(resp.status_code, 200)
    build = resp.data
    self.assertEqual(len(build['commands']), 1)
    self.assertEqual(build['commands'][0]['run_time'], 5)
    self.assertEqual(build['commands'][0]['description'], 'foo')
