def test_create_props(self): so = FullTextSearchObject( self.project, 'wiki', title='title', author='author', created=datetime(2001, 1, 1, tzinfo=utc), changed=datetime(2010, 1, 1, tzinfo=utc), oneline='oneline', tags='tags', involved='involved', popularity='popularity', body='body', action='action', ) self.assertEquals('project1', so.project) self.assertEquals('title', so.title) self.assertEquals('author', so.author) self.assertEquals(datetime(2001, 1, 1, tzinfo=utc), so.created) self.assertEquals(datetime(2010, 1, 1, tzinfo=utc), so.changed) self.assertEquals('oneline', so.oneline) self.assertEquals('tags', so.tags) self.assertEquals('involved', so.involved) self.assertEquals('popularity', so.popularity) self.assertEquals('body', so.body) self.assertEquals('action', so.action)
def test_create_resource_ignores_id(self): so = FullTextSearchObject(self.project, Resource('wiki', 'WikiStart'), id='baz') self.assertEquals('wiki', so.realm) self.assertEquals('WikiStart', so.id) self.assertEquals(Resource('wiki', 'WikiStart'), so.resource) self.assertEquals('project1:wiki:WikiStart', so.doc_id)
def test_create_realm(self): so = FullTextSearchObject(self.project, realm='bar', id='baz') self.assertEquals('bar', so.realm) self.assertEquals('baz', so.id) self.assertEquals('bar', so.resource.realm) self.assertEquals('baz', so.resource.id) self.assertEquals(Resource('bar', 'baz'), so.resource) self.assertEquals('project1:bar:baz', so.doc_id)
def test_create_resource_ignores_parent_realm_and_id(self): so = FullTextSearchObject(self.project, Resource('attachment', 'foo.txt'), parent_realm='wiki', parent_id='WikiStart') self.assertEquals('attachment', so.realm) self.assertEquals('foo.txt', so.id) self.assertEquals(None, so.parent_realm) self.assertEquals(None, so.parent_id) self.assertEquals(Resource('attachment', 'foo.txt'), so.resource) self.assertEquals('project1:attachment:foo.txt', so.doc_id)
def test_create_defaults(self): so = FullTextSearchObject(self.project, 'wiki') self.assertEquals('project1', so.project) self.assertEquals(None, so.title) self.assertEquals(None, so.author) self.assertEquals(None, so.changed) self.assertEquals(None, so.created) self.assertEquals(None, so.oneline) self.assertEquals(None, so.tags) self.assertEquals(None, so.involved) self.assertEquals(None, so.popularity) self.assertEquals(None, so.body) self.assertEquals(None, so.action) self.assertEquals(False, hasattr(so, 'unknown'))
def test_create_resource_w_parent(self): so = FullTextSearchObject( self.project, Resource('attachment', 'foo.txt', parent=Resource('wiki', 'WikiStart'))) self.assertEquals('attachment', so.realm) self.assertEquals('foo.txt', so.id) self.assertEquals('wiki', so.parent_realm) self.assertEquals('WikiStart', so.parent_id) self.assertEquals( Resource('attachment', 'foo.txt', parent=Resource('wiki', 'WikiStart')), so.resource) self.assertEquals('project1:attachment:wiki:WikiStart:foo.txt', so.doc_id)
def _fts_obj(self, project, realm, id): return FullTextSearchObject( project, realm=realm, id=id, title='Title', author='admin', created=datetime(2001, 1, 1, tzinfo=utc), # A space odyssey changed=datetime(2010, 1, 1, tzinfo=utc), # Year we make contact oneline='oneline', tags='tags', involved=['Alice', 'Bob', 'Charlie'], popularity=0, body='Lorem ipsum dolor sit amet', comments=['Comment is free', 'but facts are sacred'], )