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

Unified Diff: tests/rietveld_test.py

Issue 7840003: Make rietveld status handling saner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 3 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
« rietveld.py ('K') | « rietveld.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/rietveld_test.py
diff --git a/tests/rietveld_test.py b/tests/rietveld_test.py
index 47af5a0c5ca2dfe76990cca8a49d86aaeb01332b..5412cf26cc10112b99b00e2b763b78477e496f89 100755
--- a/tests/rietveld_test.py
+++ b/tests/rietveld_test.py
@@ -18,6 +18,25 @@ import rietveld
# Access to a protected member XX of a client class
# pylint: disable=W0212
+GIT_COPY_FULL = (
+ 'diff --git a/PRESUBMIT.py b/file_a\n'
+ 'similarity index 100%\n'
+ 'copy from PRESUBMIT.py\n'
+ 'copy to file_a\n')
+
+
+NORMAL_DIFF = (
+ '--- file_a\n'
+ '+++ file_a\n'
+ '@@ -80,10 +80,13 @@\n'
+ ' // Foo\n'
+ ' // Bar\n'
+ ' void foo() {\n'
+ '- return bar;\n'
+ '+ return foo;\n'
+ ' }\n'
+ ' \n'
+ ' \n')
def _api(files):
@@ -137,19 +156,63 @@ class RietveldTest(unittest.TestCase):
except patch.UnsupportedPatchFormat, e:
self.assertEquals('file_a', e.filename)
- def test_add_plus(self):
+ def test_add_plus_merge(self):
+ # svn:mergeinfo is dropped.
+ diff = GIT_COPY_FULL
properties = (
'\nAdded: svn:mergeinfo\n'
' Merged /branches/funky/file_b:r69-2775\n')
self.requests = [
('/api/123/456',
_api({'file_a': _file('A+', property_changes=properties)})),
+ ('/download/issue123_456_789.diff', diff),
]
- try:
- self.rietveld.get_patch(123, 456)
- self.fail()
- except patch.UnsupportedPatchFormat, e:
- self.assertEquals('file_a', e.filename)
+ patches = self.rietveld.get_patch(123, 456)
+ self.assertEquals(1, len(patches.patches))
+ self._check_patch(
+ patches.patches[0],
+ 'file_a',
+ diff,
+ is_git_diff=True,
+ is_new=True,
+ patchlevel=1)
+
+ def test_add_plus_eol_style(self):
+ diff = GIT_COPY_FULL
+ properties = '\nAdded: svn:eol-style\n + LF\n'
+ self.requests = [
+ ('/api/123/456',
+ _api({'file_a': _file('A+', property_changes=properties)})),
+ ('/download/issue123_456_789.diff', diff),
+ ]
+ patches = self.rietveld.get_patch(123, 456)
+ self.assertEquals(1, len(patches.patches))
+ self._check_patch(
+ patches.patches[0],
+ 'file_a',
+ diff,
+ is_git_diff=True,
+ is_new=True,
+ patchlevel=1,
+ svn_properties=[('svn:eol-style', 'LF')])
+
+ def test_add_empty(self):
+ # http://codereview.chromium.org/api/7530007/5001
+ # http://codereview.chromium.org/download/issue7530007_5001_4011.diff
+ diff = (
+ 'Index: scripts/master/factory/skia/__init__.py\n'
+ '===================================================================\n')
+ self.requests = [
+ ('/api/123/456', _api({'__init__.py': _file('A ', num_chunks=0)})),
+ ('/download/issue123_456_789.diff', diff),
+ ]
+ patches = self.rietveld.get_patch(123, 456)
+ self.assertEquals(1, len(patches.patches))
+ self._check_patch(
+ patches.patches[0],
+ '__init__.py',
+ diff,
+ is_new=True)
def test_delete(self):
self.requests = [
@@ -160,10 +223,26 @@ class RietveldTest(unittest.TestCase):
self._check_patch(patches.patches[0], 'file_a', None, is_delete=True)
def test_m_plus(self):
+ diff = NORMAL_DIFF
properties = '\nAdded: svn:eol-style\n + LF\n'
self.requests = [
('/api/123/456',
_api({'file_a': _file('M+', property_changes=properties)})),
+ ('/download/issue123_456_789.diff', diff),
+ ]
+ patches = self.rietveld.get_patch(123, 456)
+ self.assertEquals(1, len(patches.patches))
+ self._check_patch(
+ patches.patches[0],
+ 'file_a',
+ diff,
+ svn_properties=[('svn:eol-style', 'LF')])
+
+ def test_m_plus_unknown_prop(self):
+ properties = '\nAdded: svn:foobar\n + stuff\n'
+ self.requests = [
+ ('/api/123/456',
+ _api({'file_a': _file('M+', property_changes=properties)})),
]
try:
self.rietveld.get_patch(123, 456)
« rietveld.py ('K') | « rietveld.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698