コード例 #1
0
ファイル: test_synonyms.py プロジェクト: zctyhj/kitsune
    def test_synonyms_work_in_search_view(self):
        d1 = document(title='frob', save=True)
        d2 = document(title='glork', save=True)
        revision(document=d1, is_approved=True, save=True)
        revision(document=d2, is_approved=True, save=True)

        self.refresh()

        # First search without synonyms
        response = self.client.get(reverse('search'), {'q': 'frob'})
        doc = pq(response.content)
        header = doc.find('#search-results h2').text().strip()
        eq_(header, 'Found 1 result for frob for All Products')

        # Now add a synonym.
        synonym(from_words='frob', to_words='frob, glork', save=True)
        update_synonyms_task()
        self.refresh()

        # Forward search
        response = self.client.get(reverse('search'), {'q': 'frob'})
        doc = pq(response.content)
        header = doc.find('#search-results h2').text().strip()
        eq_(header, 'Found 2 results for frob for All Products')

        # Reverse search
        response = self.client.get(reverse('search'), {'q': 'glork'})
        doc = pq(response.content)
        header = doc.find('#search-results h2').text().strip()
        eq_(header, 'Found 1 result for glork for All Products')
コード例 #2
0
ファイル: test_synonyms.py プロジェクト: Anshdesire/kitsune
    def test_synonyms_work_in_search_view(self):
        d1 = document(title='frob', save=True)
        d2 = document(title='glork', save=True)
        revision(document=d1, is_approved=True, save=True)
        revision(document=d2, is_approved=True, save=True)

        self.refresh()

        # First search without synonyms
        response = self.client.get(reverse('search'), {'q': 'frob'})
        doc = pq(response.content)
        header = doc.find('#search-results h2').text().strip()
        eq_(header, 'Found 1 result for frob for All Products')

        # Now add a synonym.
        synonym(from_words='frob', to_words='frob, glork', save=True)
        update_synonyms_task()
        self.refresh()

        # Forward search
        response = self.client.get(reverse('search'), {'q': 'frob'})
        doc = pq(response.content)
        header = doc.find('#search-results h2').text().strip()
        eq_(header, 'Found 2 results for frob for All Products')

        # Reverse search
        response = self.client.get(reverse('search'), {'q': 'glork'})
        doc = pq(response.content)
        header = doc.find('#search-results h2').text().strip()
        eq_(header, 'Found 1 result for glork for All Products')
コード例 #3
0
ファイル: test_synonyms.py プロジェクト: zctyhj/kitsune
    def test_with_some_synonyms(self):
        synonym(from_words='foo', to_words='bar', save=True)
        synonym(from_words='baz', to_words='qux', save=True)

        _, body = es_utils.es_get_synonym_filter('en-US')

        expected = {
            'type': 'synonym',
            'synonyms': [
                'foo => bar',
                'baz => qux',
            ],
        }

        eq_(body, expected)
コード例 #4
0
ファイル: test_synonyms.py プロジェクト: Anshdesire/kitsune
    def test_with_some_synonyms(self):
        synonym(from_words='foo', to_words='bar', save=True)
        synonym(from_words='baz', to_words='qux', save=True)

        _, body = es_utils.es_get_synonym_filter('en-US')

        expected = {
            'type': 'synonym',
            'synonyms': [
                'foo => bar',
                'baz => qux',
            ],
        }

        eq_(body, expected)
コード例 #5
0
ファイル: test_synonyms.py プロジェクト: zctyhj/kitsune
 def test_serialize(self):
     syn = synonym(from_words="foo", to_words="bar", save=True)
     eq_("foo => bar", unicode(syn))
コード例 #6
0
ファイル: test_synonyms.py プロジェクト: Anshdesire/kitsune
 def test_serialize(self):
     syn = synonym(from_words="foo", to_words="bar", save=True)
     eq_("foo => bar", unicode(syn))