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

Unified Diff: tests/gcl_unittest.py

Issue 3140023: Make codereview.setting syntax more liberal and add more unit tests. (Closed)
Patch Set: Created 10 years, 4 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
« no previous file with comments | « gcl.py ('k') | tests/gclient_utils_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/gcl_unittest.py
diff --git a/tests/gcl_unittest.py b/tests/gcl_unittest.py
index e939246902c55adcc34e808dcf91777b52ca5f31..c160aa178dd81277f0799ec315a65a635f29a4a0 100755
--- a/tests/gcl_unittest.py
+++ b/tests/gcl_unittest.py
@@ -28,6 +28,9 @@ class GclTestsBase(SuperMoxTestBase):
class GclUnittest(GclTestsBase):
"""General gcl.py tests."""
+ def tearDown(self):
+ gcl.CODEREVIEW_SETTINGS = {}
+
def testMembersChanged(self):
self.mox.ReplayAll()
members = [
@@ -73,6 +76,39 @@ class GclUnittest(GclTestsBase):
# TODO(maruel): TEST ME
pass
+ def testDefaultSettings(self):
+ self.assertEquals({}, gcl.CODEREVIEW_SETTINGS)
+
+ def testGetCodeReviewSettingOk(self):
+ self.mox.StubOutWithMock(gcl, 'GetCachedFile')
+ gcl.GetCachedFile(gcl.CODEREVIEW_SETTINGS_FILE).AndReturn(
+ 'foo:bar\n'
+ '# comment\n'
+ ' c : d \n\r'
+ 'e: f')
+ self.mox.ReplayAll()
+ self.assertEquals('bar', gcl.GetCodeReviewSetting('foo'))
+ self.assertEquals('d', gcl.GetCodeReviewSetting('c'))
+ self.assertEquals('f', gcl.GetCodeReviewSetting('e'))
+ self.assertEquals('', gcl.GetCodeReviewSetting('other'))
+ self.assertEquals(
+ {'foo': 'bar', 'c': 'd', 'e': 'f', '__just_initialized': None},
+ gcl.CODEREVIEW_SETTINGS)
+
+ def testGetCodeReviewSettingFail(self):
+ self.mox.StubOutWithMock(gcl, 'GetCachedFile')
+ gcl.GetCachedFile(gcl.CODEREVIEW_SETTINGS_FILE).AndReturn(
+ 'aaa\n'
+ ' c : d \n\r'
+ 'e: f')
+ self.mox.ReplayAll()
+ try:
+ gcl.GetCodeReviewSetting('c')
+ self.fail()
+ except gcl.gclient_utils.Error:
+ pass
+ self.assertEquals({}, gcl.CODEREVIEW_SETTINGS)
+
def testGetRepositoryRootNone(self):
gcl.os.getcwd().AndReturn(self.fake_root_dir)
gcl.SVN.GetCheckoutRoot(self.fake_root_dir).AndReturn(None)
« no previous file with comments | « gcl.py ('k') | tests/gclient_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698