

def test_top_level_jsonp(self):
    api = Api()
    api.register(NoteResource())
    api.register(UserResource())
    request = HttpRequest()
    request.META = {
        'HTTP_ACCEPT': 'text/javascript',
    }
    self.GET = {
        'callback': 'foo',
    }
    resp = api.top_level(request)
    self.assertEqual(resp.status_code, 200)
    self.assertEqual(resp['content-type'].split(';')[0], 'text/javascript')
    self.assertEqual(resp.content, 'foo({"notes": {"list_endpoint": "/api/v1/notes/", "schema": "/api/v1/notes/schema/"}, "users": {"list_endpoint": "/api/v1/users/", "schema": "/api/v1/users/schema/"}})')
    request = HttpRequest()
    request.META = {
        'HTTP_ACCEPT': 'text/javascript',
    }
    request.GET = {
        'callback': '',
    }
    try:
        resp = api.top_level(request)
        self.fail("Broken callback didn't fail!")
    except BadRequest:
        pass

dataset/ETHPy150Open mozilla/inventory/vendor-local/src/django-tastypie/tests/core/tests/api.py ApiTestCase.test_top_level_jsonp/VarMisuse@53/69 `request`->`self`