'Make request and asserts on response code and response contents'

def _get_container_preview_with_error(self, usage_key, expected_code, data=None, content_contains=None):

    resp = self._get_preview(usage_key, data)
    self.assertEqual(resp.status_code, expected_code)
    if content_contains:
        self.assertIn(content_contains, resp.content)
    return resp
