def test_getCacheJSON_context_overrides_objects(self): request = LaunchpadTestRequest() view = LaunchpadView(self.getCanada(), request) IJSONRequestCache(request).objects['context'] = True with person_logged_in(self.factory.makePerson()): json_dict = simplejson.loads(view.getCacheJSON())['context'] self.assertIsCanada(json_dict)
def test_getCacheJSON_non_resource_object(self): request = LaunchpadTestRequest() view = LaunchpadView(object(), request) IJSONRequestCache(request).objects['my_bool'] = True with person_logged_in(self.factory.makePerson()): self.assertEqual('{"related_features": {}, "my_bool": true}', view.getCacheJSON())
def test_getCacheJSON_resource_object(self): request = LaunchpadTestRequest() view = LaunchpadView(object(), request) IJSONRequestCache(request).objects['country'] = self.getCanada() with person_logged_in(self.factory.makePerson()): json_dict = simplejson.loads(view.getCacheJSON())['country'] self.assertIsCanada(json_dict)
def test_getCacheJSON_resource_object(self): request = LaunchpadTestRequest() view = LaunchpadView(object(), request) IJSONRequestCache(request).objects['country'] = self.getCanada() with person_logged_in(self.factory.makePerson()): json_dict = simplejson.loads(view.getCacheJSON())['country'] self.assertIsCanada(json_dict)
def test_getCache_anonymous_obfuscated(self): request = LaunchpadTestRequest() branch = self.factory.makeBranch(name='user@domain') login_as(None) view = LaunchpadView(branch, request) self.assertIs(None, view.user) self.assertNotIn('user@domain', view.getCacheJSON())
def test_getCacheJSON_context_overrides_objects(self): request = LaunchpadTestRequest() view = LaunchpadView(self.getCanada(), request) IJSONRequestCache(request).objects['context'] = True with person_logged_in(self.factory.makePerson()): json_dict = simplejson.loads(view.getCacheJSON())['context'] self.assertIsCanada(json_dict)
def test_getCache_anonymous_obfuscated(self): request = LaunchpadTestRequest() branch = self.factory.makeBranch(name='user@domain') login_as(None) view = LaunchpadView(branch, request) self.assertIs(None, view.user) self.assertNotIn('user@domain', view.getCacheJSON())
def test_getCache_anonymous(self): request = LaunchpadTestRequest() view = LaunchpadView(self.getCanada(), request) self.assertIs(None, view.user) IJSONRequestCache(request).objects['my_bool'] = True json_dict = simplejson.loads(view.getCacheJSON()) self.assertIsCanada(json_dict['context']) self.assertIn('my_bool', json_dict)
def test_getCacheJSON_non_resource_object(self): request = LaunchpadTestRequest() view = LaunchpadView(object(), request) IJSONRequestCache(request).objects['my_bool'] = True with person_logged_in(self.factory.makePerson()): self.assertEqual( '{"related_features": {}, "my_bool": true}', view.getCacheJSON())
def test_getCache_anonymous(self): request = LaunchpadTestRequest() view = LaunchpadView(self.getCanada(), request) self.assertIs(None, view.user) IJSONRequestCache(request).objects['my_bool'] = True json_dict = simplejson.loads(view.getCacheJSON()) self.assertIsCanada(json_dict['context']) self.assertIn('my_bool', json_dict)
def test_getCacheJSON_resource_context(self): view = LaunchpadView(self.getCanada(), LaunchpadTestRequest()) json_dict = simplejson.loads(view.getCacheJSON())['context'] self.assertIsCanada(json_dict)
def test_getCacheJSON_non_resource_context(self): view = LaunchpadView(object(), LaunchpadTestRequest()) self.assertEqual('{"related_features": {}}', view.getCacheJSON())
def test_getCacheJSON_resource_context(self): view = LaunchpadView(self.getCanada(), LaunchpadTestRequest()) json_dict = simplejson.loads(view.getCacheJSON())['context'] self.assertIsCanada(json_dict)
def test_getCacheJSON_non_resource_context(self): view = LaunchpadView(object(), LaunchpadTestRequest()) self.assertEqual('{"related_features": {}}', view.getCacheJSON())