OLD | NEW |
(Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is govered by a BSD-style |
| 3 # license that can be found in the LICENSE file or at |
| 4 # https://developers.google.com/open-source/licenses/bsd |
| 5 |
| 6 """Tests for the searchpipeline module.""" |
| 7 |
| 8 import unittest |
| 9 |
| 10 from proto import ast_pb2 |
| 11 from proto import tracker_pb2 |
| 12 from search import searchpipeline |
| 13 from services import service_manager |
| 14 from testing import fake |
| 15 from tracker import tracker_bizobj |
| 16 |
| 17 |
| 18 class SearchPipelineTest(unittest.TestCase): |
| 19 |
| 20 def setUp(self): |
| 21 self.cnxn = 'fake cnxn' |
| 22 self.config = tracker_bizobj.MakeDefaultProjectIssueConfig(789) |
| 23 self.services = service_manager.Services( |
| 24 user=fake.UserService(), |
| 25 project=fake.ProjectService(), |
| 26 issue=fake.IssueService(), |
| 27 config=fake.ConfigService()) |
| 28 self.services.user.TestAddUser('a@example.com', 111L) |
| 29 |
| 30 def testIsStarredRE(self): |
| 31 """IS_STARRED_RE matches only the is:starred term.""" |
| 32 input_output = { |
| 33 'something:else': 'something:else', |
| 34 'genesis:starred': 'genesis:starred', |
| 35 'is:starred-in-bookmarks': 'is:starred-in-bookmarks', |
| 36 'is:starred': 'foo', |
| 37 'Is:starred': 'foo', |
| 38 'is:STARRED': 'foo', |
| 39 'is:starred is:open': 'foo is:open', |
| 40 'is:open is:starred': 'is:open foo', |
| 41 } |
| 42 for i, o in input_output.items(): |
| 43 self.assertEqual(o, searchpipeline.IS_STARRED_RE.sub('foo', i)) |
| 44 |
| 45 def testMeRE(self): |
| 46 """ME_RE matches only the 'me' value keyword.""" |
| 47 input_output = { |
| 48 'something:else': 'something:else', |
| 49 'else:some': 'else:some', |
| 50 'me': 'me', # It needs to have a ":" in front. |
| 51 'cc:me-team': 'cc:me-team', |
| 52 'cc:me=domain@otherdomain': 'cc:me=domain@otherdomain', |
| 53 'cc:me@example.com': 'cc:me@example.com', |
| 54 'me:the-boss': 'me:the-boss', |
| 55 'cc:me': 'cc:foo', |
| 56 'cc=me': 'cc=foo', |
| 57 'owner:Me': 'owner:foo', |
| 58 'reporter:ME': 'reporter:foo', |
| 59 'cc:me is:open': 'cc:foo is:open', |
| 60 'is:open cc:me': 'is:open cc:foo', |
| 61 } |
| 62 for i, o in input_output.items(): |
| 63 self.assertEqual(o, searchpipeline.ME_RE.sub('foo', i)) |
| 64 |
| 65 def testAccumulateIssueProjectsAndConfigs(self): |
| 66 pass # TODO(jrobbins): write tests |
| 67 |
| 68 def testReplaceKeywordsWithUserID(self): |
| 69 pass # TODO(jrobbins): write tests |
| 70 |
| 71 |
| 72 if __name__ == '__main__': |
| 73 unittest.main() |
OLD | NEW |