Exemplo n.º 1
0
 def testVocabularyMissing(self):
     view = PersonalizedVocabularyView(self.portal, self.request)
     self.request.form.update({
         'name': 'vocabulary.that.does.not.exist',
     })
     data = json.loads(view())
     self.assertEquals(data['error'], 'Vocabulary lookup not allowed')
Exemplo n.º 2
0
 def testVocabularyQueryString_utf8(self):
     """Test querying a class based vocabulary with a search string.
     """
     view = PersonalizedVocabularyView(self.doc2, self.request)
     self.request.form.update({'query': u'a_3_♥'})
     data = json.loads(view())
     self.assertEquals(len(data['results']), 1)
Exemplo n.º 3
0
 def testVocabularyNoResults(self):
     """Tests that the widgets displays correctly
     """
     view = PersonalizedVocabularyView(self.doc2, self.request)
     self.request.form.update({'query': 'nosuch'})
     data = json.loads(view())
     self.assertEquals(len(data['results']), 0)
Exemplo n.º 4
0
 def testVocabularyNoPersonalTagsYet(self):
     # user has no tags
     login(self.portal, 'mary_jane')
     # doc2 has no tags
     view = PersonalizedVocabularyView(self.doc2, self.request)
     data = json.loads(view())
     # expect john_doe tags on doc1
     self.assertEquals(len(data['results']), self.num_tags)
Exemplo n.º 5
0
 def testVocabularyQueryStringPartial(self):
     """Test querying a class based vocabulary with a search string.
     """
     view = PersonalizedVocabularyView(self.doc2, self.request)
     self.request.form.update({
         'query': 'a_'  # matches a_?_♥
     })
     data = json.loads(view())
     self.assertEquals(len(data['results']), 5)
Exemplo n.º 6
0
 def testVocabularyPersonalizedContextTagsMany(self):
     # let john_doe fill up the doc1 tag space
     self.tag(self.doc1, *['many_%02d' % i for i in xrange(100)])
     login(self.portal, 'mary_jane')
     view = PersonalizedVocabularyView(self.doc1, self.request)
     data = json.loads(view())
     # we expect to find all of john_doe's context tags
     self.assertEquals(len(data['results']), self.num_tags + 100)
     self.assertFalse('a_' in data['results'])
Exemplo n.º 7
0
 def testVocabularyPersonalizedContextTags(self):
     # let john_doe pollute the global tag space via doc2
     self.tag(self.doc2, *['many_%02d' % i for i in xrange(100)])
     login(self.portal, 'mary_jane')
     view = PersonalizedVocabularyView(self.doc1, self.request)
     data = json.loads(view())
     # we expect to find the a_ and b_ doc1 tags only
     self.assertEquals(len(data['results']), self.num_tags)
     self.assertFalse('a_' in data['results'])
Exemplo n.º 8
0
 def testVocabularyQueryStringUnidecodeQuery(self):
     """Test querying a class based vocabulary with a search string.
     """
     view = PersonalizedVocabularyView(self.doc2, self.request)
     self.request.form.update({
         'query': u'RÖD'  # matches RødgrØd and rOdgrod
     })
     data = json.loads(view())
     self.assertEquals(len(data['results']), 2)
Exemplo n.º 9
0
 def testVocabularySorted(self):
     login(self.portal, 'mary_jane')
     self.tag(self.doc1, 'Z tag')
     self.tag(self.doc1, 'A tag')
     self.tag(self.doc1, 'C tag')
     view = PersonalizedVocabularyView(self.doc2, self.request)
     data = json.loads(view())
     tags = [x['text'] for x in data['results']]
     self.assertEquals(tags[0], u'A tag')
     self.assertEquals(tags[1], u'C tag')
     self.assertEquals(tags[2], u'Z tag')
Exemplo n.º 10
0
 def testVocabularyPersonalizedUserContentTags(self):
     # mary sets many tags
     login(self.portal, 'mary_jane')
     doc3 = api.content.create(container=self.portal,
                               type='Document',
                               id='doc3',
                               title='Doc 3')
     self.tag(doc3, *['many_%02d' % i for i in xrange(100)])
     # john doesn't see those
     login(self.portal, 'john_doe')
     view = PersonalizedVocabularyView(self.doc2, self.request)
     data = json.loads(view())
     # we expect to find john_doe a_* and b_* suggestions only
     self.assertEquals(len(data['results']), max_suggest)
     self.assertFalse('many_' in data['results'])
Exemplo n.º 11
0
 def testVocabularyNoQuery(self):
     """Test the keyword vocab without query narrowing."""
     view = PersonalizedVocabularyView(self.doc2, self.request)
     data = json.loads(view())
     self.assertEquals(len(data['results']), max_suggest)
Exemplo n.º 12
0
 def testVocabularyUnauthorized(self):
     setRoles(self.portal, 'john_doe', [])
     view = PersonalizedVocabularyView(self.portal, self.request)
     data = json.loads(view())
     self.assertEquals(data['error'], 'Vocabulary lookup not allowed')