Пример #1
0
 def test_adds_incremental_changes_to_index(self):
     # make some changes
     self.site.change(added={'content/newentry.txt': 'newentry'},
                      modified={'content/food.txt': 'newfood'},
                      deleted=['content/random.txt'])
     with self.app.app_context():
         self.assertEquals(3, len(search('')))
         self.assertEquals(1, len(search('content:blah')))
         self.assertEquals(1, len(search('content:newentry')))
         self.assertEquals(1, len(search('content:newfood')))
Пример #2
0
def _fetch_date_for_name(name):
    infos = search('fullname:'+name)
    create_time = None
    if infos:
        datefield = current_app.config['YAWT_ARCHIVE_DATEFIELD']
        create_time = getattr(infos[0], datefield)
    return create_time
Пример #3
0
    def test_search_returns_results(self):
        ix = _create_index()
        writer = ix.writer()
        article = _article('cooking/indian/madras',
                           [u'spicy', u'curry'],
                           'this is an awesome article')
        doc = _field_values(article)
        writer.add_document(**doc)

        article = _article('reading/scifi/clarke',
                           [u'monolith', u'alien'],
                           'this is a crappy article')
        doc = _field_values(article)
        writer.add_document(**doc)
        writer.commit()

        articles = search('tags:monolith')
        self.assertEquals(1, len(articles))
        self.assertEquals('reading/scifi/clarke', articles[0].fullname)
Пример #4
0
    def test_clears_index_and_reindexes_all_articles_on_walk(self):
        # quick check that there's something in the index
        self.assertEquals(3, len(search('')))
        self.assertEquals(1, len(search('content:blah')))
        self.assertEquals(1, len(search('content:random')))
        self.assertEquals(1, len(search('content:food')))

        # change contents completely
        self.site.delete_file('content/food.txt')
        self.site.delete_file('content/random.txt')
        self.site.delete_file('content/entry.txt')
        self.site.save_file('content/newentry.txt', 'newentry')

        with self.app.app_context():
            walk = Walk()
            walk.run()

            # now the extra file should be indexed
            self.assertEquals(1, len(search('')))
            self.assertEquals(1, len(search('content:newentry')))
Пример #5
0
 def _tags_for_name(self, name):
     infos = search("fullname:" + name)
     tags = []
     if infos and hasattr(infos[0], "tags") and infos[0].tags:
         tags = infos[0].tags
     return tags