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

Unified Diff: appengine/monorail/testing/test/fake_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/testing/test/fake_test.py
diff --git a/appengine/monorail/testing/test/fake_test.py b/appengine/monorail/testing/test/fake_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..a58a44d6337fde15d5c928cb1384ddb12b741a74
--- /dev/null
+++ b/appengine/monorail/testing/test/fake_test.py
@@ -0,0 +1,67 @@
+# 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 the fake module."""
+
+import inspect
+import unittest
+
+from services import cachemanager_svc
+from services import config_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,
+ }
+
+
+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.iteritems():
+ 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)
+ if 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 = real_spec[3] and len(real_spec[3]) or 0
+ fake_kw_len = fake_spec[3] and len(fake_spec[3]) or 0
+
+ self.assertEquals(
+ 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.assertEquals(
+ real_kw_len, fake_kw_len,
+ 'Unequal number of kwargs on %s.%s' % (fake_cls.__name__, name))
+ if real_kw_len:
+ self.assertEquals(
+ real_spec[0][-real_kw_len:],
+ fake_spec[0][-fake_kw_len:],
+ 'Mismatched kwargs on %s.%s' % (fake_cls.__name__, name))
+ self.assertEquals(
+ real_spec[3], fake_spec[3],
+ 'Mismatched kwarg defaults on %s.%s' % (fake_cls.__name__, name))
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « appengine/monorail/testing/test/__init__.py ('k') | appengine/monorail/testing/test/testing_helpers_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698