Пример #1
0
 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)
Пример #2
0
 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())
Пример #3
0
 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)
Пример #4
0
 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)
Пример #5
0
 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())
Пример #6
0
 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)
Пример #7
0
 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())
Пример #8
0
 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)
Пример #9
0
 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())
Пример #10
0
 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)
Пример #11
0
 def test_getCacheJSON_resource_context(self):
     view = LaunchpadView(self.getCanada(), LaunchpadTestRequest())
     json_dict = simplejson.loads(view.getCacheJSON())['context']
     self.assertIsCanada(json_dict)
Пример #12
0
 def test_getCacheJSON_non_resource_context(self):
     view = LaunchpadView(object(), LaunchpadTestRequest())
     self.assertEqual('{"related_features": {}}', view.getCacheJSON())
Пример #13
0
 def test_getCacheJSON_resource_context(self):
     view = LaunchpadView(self.getCanada(), LaunchpadTestRequest())
     json_dict = simplejson.loads(view.getCacheJSON())['context']
     self.assertIsCanada(json_dict)
Пример #14
0
 def test_getCacheJSON_non_resource_context(self):
     view = LaunchpadView(object(), LaunchpadTestRequest())
     self.assertEqual('{"related_features": {}}', view.getCacheJSON())