def testCreateIssueSearchDocuments_Normal(self): self.SetUpCreateIssueSearchDocuments() self.mox.ReplayAll() config_dict = {123: tracker_bizobj.MakeDefaultProjectIssueConfig(123)} tracker_fulltext._CreateIssueSearchDocuments( [self.issue], {self.issue.issue_id: [self.comment]}, self.users_by_id, config_dict) self.mox.VerifyAll() self.assertEqual(1, len(self.docs)) issue_doc = self.docs[0] self.assertEqual(5, len(issue_doc.fields)) self.assertEqual(123, issue_doc.fields[0].value) self.assertEqual('test summary', issue_doc.fields[1].value) self.assertEqual('[email protected] comment content hello.c hello.h', issue_doc.fields[3].value) self.assertEqual('', issue_doc.fields[4].value)
def testCreateIssueSearchDocuments_NoIndexableComments(self): """Sometimes all comments on a issue are spam or deleted.""" self.SetUpCreateIssueSearchDocuments() self.mox.ReplayAll() config_dict = {123: tracker_bizobj.MakeDefaultProjectIssueConfig(123)} self.comment.deleted_by = 111 tracker_fulltext._CreateIssueSearchDocuments( [self.issue], {self.issue.issue_id: [self.comment]}, self.users_by_id, config_dict) self.mox.VerifyAll() self.assertEqual(1, len(self.docs)) issue_doc = self.docs[0] self.assertEqual(5, len(issue_doc.fields)) self.assertEqual(123, issue_doc.fields[0].value) self.assertEqual('test summary', issue_doc.fields[1].value) self.assertEqual('', issue_doc.fields[3].value) self.assertEqual('', issue_doc.fields[4].value)
def testCreateIssueSearchDocuments_CustomFields(self): self.SetUpCreateIssueSearchDocuments() self.mox.ReplayAll() config = tracker_bizobj.MakeDefaultProjectIssueConfig(123) config_dict = {123: tracker_bizobj.MakeDefaultProjectIssueConfig(123)} int_field = tracker_bizobj.MakeFieldDef( 1, 123, 'CustomInt', tracker_pb2.FieldTypes.INT_TYPE, None, False, False, False, None, None, None, None, False, None, None, None, 'no_action', 'A custom int field', False) int_field_value = tracker_bizobj.MakeFieldValue( 1, 42, None, None, False, None, None) str_field = tracker_bizobj.MakeFieldDef( 2, 123, 'CustomStr', tracker_pb2.FieldTypes.STR_TYPE, None, False, False, False, None, None, None, None, False, None, None, None, 'no_action', 'A custom string field', False) str_field_value = tracker_bizobj.MakeFieldValue( 2, None, u'\xf0\x9f\x92\x96\xef\xb8\x8f', None, None, None, False) # TODO(jrobbins): user-type field 3 date_field = tracker_bizobj.MakeFieldDef( 4, 123, 'CustomDate', tracker_pb2.FieldTypes.DATE_TYPE, None, False, False, False, None, None, None, None, False, None, None, None, 'no_action', 'A custom date field', False) date_field_value = tracker_bizobj.MakeFieldValue( 4, None, None, None, 1234567890, None, False) config.field_defs.extend([int_field, str_field, date_field]) self.issue.field_values.extend( [int_field_value, str_field_value, date_field_value]) tracker_fulltext._CreateIssueSearchDocuments( [self.issue], {self.issue.issue_id: [self.comment]}, self.users_by_id, config_dict) self.mox.VerifyAll() self.assertEqual(1, len(self.docs)) issue_doc = self.docs[0] metadata = issue_doc.fields[2] self.assertEqual( u'New [email protected] [] 42 \xf0\x9f\x92\x96\xef\xb8\x8f 2009-02-13 ', metadata.value)