Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: appengine/monorail/tracker/test/issueadvsearch_test.py

Issue 1868553004: Open Source Monorail (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/monorail/tracker/test/issueadvsearch_test.py
diff --git a/appengine/monorail/tracker/test/issueadvsearch_test.py b/appengine/monorail/tracker/test/issueadvsearch_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..a5439a54acdcf85cdf3dc813e779cd03e27fea1f
--- /dev/null
+++ b/appengine/monorail/tracker/test/issueadvsearch_test.py
@@ -0,0 +1,71 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is govered by a BSD-style
+# license that can be found in the LICENSE file or at
+# https://developers.google.com/open-source/licenses/bsd
+
+"""Tests for monorail.tracker.issueadvsearch."""
+
+import unittest
+
+from services import service_manager
+from testing import fake
+from testing import testing_helpers
+from tracker import issueadvsearch
+
+class IssueAdvSearchTest(unittest.TestCase):
+
+ def setUp(self):
+ self.services = service_manager.Services(
+ config=fake.ConfigService(),
+ issue=fake.IssueService(),
+ user=fake.UserService(),
+ project=fake.ProjectService())
+ self.project = self.services.project.TestAddProject('proj', project_id=987)
+ self.servlet = issueadvsearch.IssueAdvancedSearch(
+ 'req', 'res', services=self.services)
+
+ def testGatherData(self):
+ mr = testing_helpers.MakeMonorailRequest(
+ path='/p/proj/issues/advsearch')
+ page_data = self.servlet.GatherPageData(mr)
+
+ self.assertTrue('issue_tab_mode' in page_data)
+ self.assertTrue('page_perms' in page_data)
+
+ def testProcessFormData(self):
+ mr = testing_helpers.MakeMonorailRequest(
+ path='/p/proj/issues/advsearch')
+ post_data = {}
+ url = self.servlet.ProcessFormData(mr, post_data)
+ self.assertTrue('can=2' in url)
+
+ post_data['can'] = 42
+ url = self.servlet.ProcessFormData(mr, post_data)
+ self.assertTrue('can=42' in url)
+
+ post_data['starcount'] = 42
+ url = self.servlet.ProcessFormData(mr, post_data)
+ self.assertTrue('starcount%3A42' in url)
+
+ def _testAND(self, operator, field, post_data, query):
+ self.servlet._AccumulateANDTerm(operator, field, post_data, query)
+ return query
+
+ def test_AccumulateANDTerm(self):
+ query = self._testAND('', 'foo', {'foo':'bar'}, [])
+ self.assertEquals(['bar'], query)
+
+ query = self._testAND('', 'bar', {'bar':'baz=zippy'}, query)
+ self.assertEquals(['bar', 'baz', 'zippy'], query)
+
+ def _testOR(self, operator, field, post_data, query):
+ self.servlet._AccumulateORTerm(operator, field, post_data, query)
+ return query
+
+ def test_AccumulateORTerm(self):
+ query = self._testOR('', 'foo', {'foo':'bar'}, [])
+ self.assertEquals(['bar'], query)
+
+ query = self._testOR('', 'bar', {'bar':'baz=zippy'}, query)
+ self.assertEquals(['bar', 'baz,zippy'], query)
+
« no previous file with comments | « appengine/monorail/tracker/test/issueadmin_test.py ('k') | appengine/monorail/tracker/test/issueattachment_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698