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: bin/loman_unittest.py

Issue 3400019: loman: Add support for adding elements from default.xml (Closed) Base URL: http://git.chromium.org/git/crosutils.git
Patch Set: Fixed. Created 10 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
« no previous file with comments | « bin/loman.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bin/loman_unittest.py
diff --git a/bin/loman_unittest.py b/bin/loman_unittest.py
index 4782ac32b50af694a99edd94f019f39f4500325b..5788f0378aa84b9ee32d58115d858ad97b0a92f8 100755
--- a/bin/loman_unittest.py
+++ b/bin/loman_unittest.py
@@ -38,6 +38,13 @@ class LocalManifestTest(unittest.TestCase):
ptree.Parse()
self.assertEqual(ptree.ToString(), self.utf8 + self.tiny_manifest)
+ def testGetProject(self):
+ ptree = loman.LocalManifest('<manifest>\n</manifest>')
+ ptree.Parse()
+ ptree.AddProject('foo', 'path/to/foo')
+ project = ptree.GetProject('foo')
+ self.assertEqual(project.attrib['name'], 'foo')
+
def testAddNew(self):
ptree = loman.LocalManifest('<manifest>\n</manifest>')
ptree.Parse()
@@ -48,6 +55,19 @@ class LocalManifestTest(unittest.TestCase):
'<project name="foo" path="path/to/foo" workon="True" />\n'
'</manifest>')
+ def testAddNewElement(self):
+ dtree = loman.LocalManifest('<manifest>\n</manifest>')
+ dtree.Parse()
+ dtree.AddProject('foo', 'path/to/foo')
+ ptree = loman.LocalManifest('<manifest>\n</manifest>')
+ ptree.Parse()
+ ptree.AddWorkonProjectElement(dtree.GetProject('foo'))
+ self.assertEqual(
+ ptree.ToString(),
+ self.utf8 + '<manifest>\n'
+ '<project name="foo" path="path/to/foo" workon="True" />\n'
+ '</manifest>')
+
def testAddDup(self):
ptree = loman.LocalManifest('<manifest>\n</manifest>')
ptree.Parse()
@@ -83,30 +103,69 @@ class MainTest(unittest.TestCase):
self.assertTrue(sys.stderr.getvalue().endswith(err_msg))
def testSimpleAdd(self):
+ default = tempfile.NamedTemporaryFile('w')
+ print >> default, '<manifest>\n' \
+ '<project name="foo" path="path/to/foo" />\n' \
+ '</manifest>\n'
+ default.flush()
+ os.fsync(default.fileno())
temp = tempfile.NamedTemporaryFile('w')
print >> temp, '<manifest>\n</manifest>'
temp.flush()
os.fsync(temp.fileno())
- loman.main(['loman', 'add', '--workon', '-f',
- temp.name, 'foo', 'path/to/foo'])
+ loman.main(['loman', 'add', '--workon', '-f', temp.name,
+ '-d', default.name, 'foo'])
self.assertEqual(
open(temp.name, 'r').read(),
self.utf8 + '<manifest>\n'
'<project name="foo" path="path/to/foo" workon="True" />\n'
'</manifest>\n')
+ def testIgnoredPath(self):
+ default = tempfile.NamedTemporaryFile('w')
+ print >> default, '<manifest>\n' \
+ '<project name="foo" path="path/to/foo" />\n' \
+ '</manifest>\n'
+ default.flush()
+ os.fsync(default.fileno())
+ temp = tempfile.NamedTemporaryFile('w')
+ print >> temp, '<manifest>\n</manifest>'
+ temp.flush()
+ os.fsync(temp.fileno())
+ loman.main(['loman', 'add', '--workon', '-f', temp.name,
+ '-d', default.name, 'foo'])
+
def testAddDup(self):
+ default = tempfile.NamedTemporaryFile('w')
+ print >> default, '<manifest>\n' \
+ '<project name="foo" path="path/to/foo" />\n' \
+ '</manifest>\n'
+ default.flush()
+ os.fsync(default.fileno())
+ temp = tempfile.NamedTemporaryFile('w')
+ print >> temp, '<manifest>\n' \
+ '<project name="foo" path="bad/path/to/foo" />\n' \
+ '</manifest>\n'
+ temp.flush()
+ os.fsync(temp.fileno())
+ self.assertRaises(SystemExit, loman.main,
+ ['loman', 'add', '--workon', '-f', temp.name,
+ '-d', default.name, 'foo'])
+
+ def testAddNonexistant(self):
+ default = tempfile.NamedTemporaryFile('w')
+ print >> default, '<manifest>\n' \
+ '<project name="foo" path="path/to/foo" />\n' \
+ '</manifest>\n'
+ default.flush()
+ os.fsync(default.fileno())
temp = tempfile.NamedTemporaryFile('w')
print >> temp, '<manifest>\n</manifest>'
temp.flush()
os.fsync(temp.fileno())
- loman.main(['loman', 'add', '--workon', '-f',
- temp.name, 'foo', 'path/to/foo'])
- loman.main(['loman', 'add', '--workon', '-f',
- temp.name, 'foo', 'path/to/foo'])
self.assertRaises(SystemExit, loman.main,
- ['loman', 'add', '--workon', '-f',
- temp.name, 'foo', 'path/foo'])
+ ['loman', 'add', '--workon', '-f', temp.name,
+ '-d', default.name, 'bar'])
if __name__ == '__main__':
« no previous file with comments | « bin/loman.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698