Project import generated by Copybara.

GitOrigin-RevId: d9e9e3fb4e31372ec1fb43b178994ca78fa8fe70
diff --git a/testing/test/__init__.py b/testing/test/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/testing/test/__init__.py
diff --git a/testing/test/fake_test.py b/testing/test/fake_test.py
new file mode 100644
index 0000000..c098236
--- /dev/null
+++ b/testing/test/fake_test.py
@@ -0,0 +1,67 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed 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 the fake module."""
+from __future__ import print_function
+from __future__ import division
+from __future__ import absolute_import
+
+import inspect
+import unittest
+
+from services import cachemanager_svc
+from services import config_svc
+from services import features_svc
+from services import issue_svc
+from services import project_svc
+from services import star_svc
+from services import user_svc
+from services import usergroup_svc
+from testing import fake
+
+fake_class_map = {
+    fake.AbstractStarService: star_svc.AbstractStarService,
+    fake.CacheManager: cachemanager_svc.CacheManager,
+    fake.ProjectService: project_svc.ProjectService,
+    fake.ConfigService: config_svc.ConfigService,
+    fake.IssueService: issue_svc.IssueService,
+    fake.UserGroupService: usergroup_svc.UserGroupService,
+    fake.UserService: user_svc.UserService,
+    fake.FeaturesService: features_svc.FeaturesService,
+    }
+
+
+class FakeMetaTest(unittest.TestCase):
+
+  def testFunctionsHaveSameSignatures(self):
+    """Verify that the fake class methods match the real ones."""
+    for fake_cls, real_cls in fake_class_map.items():
+      fake_attrs = set(dir(fake_cls))
+      real_attrs = set(dir(real_cls))
+      both_attrs = fake_attrs.intersection(real_attrs)
+      to_test = [x for x in both_attrs if '__' not in x]
+      for name in to_test:
+        real_attr = getattr(real_cls, name)
+        assert inspect.ismethod(real_attr)
+        real_spec = inspect.getargspec(real_attr)
+        fake_spec = inspect.getargspec(getattr(fake_cls, name))
+        # check same number of args and kwargs
+        real_kw_len = len(real_spec[3]) if real_spec[3] else 0
+        fake_kw_len = len(fake_spec[3]) if fake_spec[3] else 0
+
+        self.assertEqual(
+            len(real_spec[0]) - real_kw_len,
+            len(fake_spec[0]) - fake_kw_len,
+            'Unequal number of args on %s.%s' % (fake_cls.__name__, name))
+        self.assertEqual(
+            real_kw_len, fake_kw_len,
+            'Unequal number of kwargs on %s.%s' % (fake_cls.__name__, name))
+        if real_kw_len:
+          self.assertEqual(
+              real_spec[0][-real_kw_len:], fake_spec[0][-fake_kw_len:],
+              'Mismatched kwargs on %s.%s' % (fake_cls.__name__, name))
+        self.assertEqual(
+            real_spec[3], fake_spec[3],
+            'Mismatched kwarg defaults on %s.%s' % (fake_cls.__name__, name))
diff --git a/testing/test/testing_helpers_test.py b/testing/test/testing_helpers_test.py
new file mode 100644
index 0000000..7493b04
--- /dev/null
+++ b/testing/test/testing_helpers_test.py
@@ -0,0 +1,74 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed 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 the testing_helpers module."""
+from __future__ import print_function
+from __future__ import division
+from __future__ import absolute_import
+
+import unittest
+
+from testing import testing_helpers
+
+
+class TestingHelpersTest(unittest.TestCase):
+
+  def testMakeMonorailRequest(self):
+    mr = testing_helpers.MakeMonorailRequest(
+        path='/foo?key1=2&key2=&key3')
+
+    self.assertEqual(None, mr.GetIntParam('foo'))
+    self.assertEqual(2, mr.GetIntParam('key1'))
+    self.assertEqual(None, mr.GetIntParam('key2'))
+    self.assertEqual(None, mr.GetIntParam('key3'))
+    self.assertEqual(3, mr.GetIntParam('key2', default_value=3))
+    self.assertEqual(3, mr.GetIntParam('foo', default_value=3))
+
+  def testGetRequestObjectsBasics(self):
+    request, mr = testing_helpers.GetRequestObjects(
+        path='/foo/bar/wee?sna=foo',
+        params={'ya': 'hoo'}, method='POST')
+
+    # supplied as part of the url
+    self.assertEqual('foo', mr.GetParam('sna'))
+
+    # supplied as a param
+    self.assertEqual('hoo', mr.GetParam('ya'))
+
+    # default Host header
+    self.assertEqual('127.0.0.1', request.host)
+
+  def testGetRequestObjectsHeaders(self):
+    # with some headers
+    request, _mr = testing_helpers.GetRequestObjects(
+        headers={'Accept-Language': 'en', 'Host': 'pickledsheep.com'},
+        path='/foo/bar/wee?sna=foo')
+
+    # default Host header
+    self.assertEqual('pickledsheep.com', request.host)
+
+    # user specified headers
+    self.assertEqual('en', request.headers['Accept-Language'])
+
+  def testGetRequestObjectsUserInfo(self):
+    user_id = '123'
+
+    _request, mr = testing_helpers.GetRequestObjects(
+        user_info={'user_id': user_id})
+
+    self.assertEqual(user_id, mr.auth.user_id)
+
+
+class BlankTest(unittest.TestCase):
+
+  def testBlank(self):
+    blank = testing_helpers.Blank(
+        foo='foo',
+        bar=123,
+        inc=lambda x: x + 1)
+
+    self.assertEqual('foo', blank.foo)
+    self.assertEqual(123, blank.bar)
+    self.assertEqual(5, blank.inc(4))