| 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__':
|
|
|