summaryrefslogtreecommitdiffstats
path: root/tests/test_git_superproject.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_git_superproject.py')
-rw-r--r--tests/test_git_superproject.py63
1 files changed, 30 insertions, 33 deletions
diff --git a/tests/test_git_superproject.py b/tests/test_git_superproject.py
index a24fc7f0..1e7b1201 100644
--- a/tests/test_git_superproject.py
+++ b/tests/test_git_superproject.py
@@ -68,8 +68,10 @@ class SuperprojectTestCase(unittest.TestCase):
68 <project path="art" name="platform/art" groups="notdefault,platform-""" + self.platform + """ 68 <project path="art" name="platform/art" groups="notdefault,platform-""" + self.platform + """
69 " /></manifest> 69 " /></manifest>
70""") 70""")
71 self._superproject = git_superproject.Superproject(manifest, self.repodir, 71 self._superproject = git_superproject.Superproject(
72 self.git_event_log) 72 manifest, name='superproject',
73 remote=manifest.remotes.get('default-remote').ToRemoteSpec('superproject'),
74 revision='refs/heads/main')
73 75
74 def tearDown(self): 76 def tearDown(self):
75 """Tear down superproject every time.""" 77 """Tear down superproject every time."""
@@ -125,12 +127,7 @@ class SuperprojectTestCase(unittest.TestCase):
125<manifest> 127<manifest>
126</manifest> 128</manifest>
127""") 129""")
128 superproject = git_superproject.Superproject(manifest, self.repodir, self.git_event_log) 130 self.assertIsNone(manifest.superproject)
129 # Test that exit condition is false when there is no superproject tag.
130 sync_result = superproject.Sync()
131 self.assertFalse(sync_result.success)
132 self.assertFalse(sync_result.fatal)
133 self.verifyErrorEvent()
134 131
135 def test_superproject_get_superproject_invalid_url(self): 132 def test_superproject_get_superproject_invalid_url(self):
136 """Test with an invalid url.""" 133 """Test with an invalid url."""
@@ -141,8 +138,11 @@ class SuperprojectTestCase(unittest.TestCase):
141 <superproject name="superproject"/> 138 <superproject name="superproject"/>
142</manifest> 139</manifest>
143""") 140""")
144 superproject = git_superproject.Superproject(manifest, self.repodir, self.git_event_log) 141 superproject = git_superproject.Superproject(
145 sync_result = superproject.Sync() 142 manifest, name='superproject',
143 remote=manifest.remotes.get('test-remote').ToRemoteSpec('superproject'),
144 revision='refs/heads/main')
145 sync_result = superproject.Sync(self.git_event_log)
146 self.assertFalse(sync_result.success) 146 self.assertFalse(sync_result.success)
147 self.assertTrue(sync_result.fatal) 147 self.assertTrue(sync_result.fatal)
148 148
@@ -155,17 +155,19 @@ class SuperprojectTestCase(unittest.TestCase):
155 <superproject name="superproject"/> 155 <superproject name="superproject"/>
156</manifest> 156</manifest>
157""") 157""")
158 self._superproject = git_superproject.Superproject(manifest, self.repodir, 158 self._superproject = git_superproject.Superproject(
159 self.git_event_log) 159 manifest, name='superproject',
160 remote=manifest.remotes.get('test-remote').ToRemoteSpec('superproject'),
161 revision='refs/heads/main')
160 with mock.patch.object(self._superproject, '_branch', 'junk'): 162 with mock.patch.object(self._superproject, '_branch', 'junk'):
161 sync_result = self._superproject.Sync() 163 sync_result = self._superproject.Sync(self.git_event_log)
162 self.assertFalse(sync_result.success) 164 self.assertFalse(sync_result.success)
163 self.assertTrue(sync_result.fatal) 165 self.assertTrue(sync_result.fatal)
164 166
165 def test_superproject_get_superproject_mock_init(self): 167 def test_superproject_get_superproject_mock_init(self):
166 """Test with _Init failing.""" 168 """Test with _Init failing."""
167 with mock.patch.object(self._superproject, '_Init', return_value=False): 169 with mock.patch.object(self._superproject, '_Init', return_value=False):
168 sync_result = self._superproject.Sync() 170 sync_result = self._superproject.Sync(self.git_event_log)
169 self.assertFalse(sync_result.success) 171 self.assertFalse(sync_result.success)
170 self.assertTrue(sync_result.fatal) 172 self.assertTrue(sync_result.fatal)
171 173
@@ -174,7 +176,7 @@ class SuperprojectTestCase(unittest.TestCase):
174 with mock.patch.object(self._superproject, '_Init', return_value=True): 176 with mock.patch.object(self._superproject, '_Init', return_value=True):
175 os.mkdir(self._superproject._superproject_path) 177 os.mkdir(self._superproject._superproject_path)
176 with mock.patch.object(self._superproject, '_Fetch', return_value=False): 178 with mock.patch.object(self._superproject, '_Fetch', return_value=False):
177 sync_result = self._superproject.Sync() 179 sync_result = self._superproject.Sync(self.git_event_log)
178 self.assertFalse(sync_result.success) 180 self.assertFalse(sync_result.success)
179 self.assertTrue(sync_result.fatal) 181 self.assertTrue(sync_result.fatal)
180 182
@@ -230,7 +232,7 @@ class SuperprojectTestCase(unittest.TestCase):
230 return_value=data): 232 return_value=data):
231 # Create temporary directory so that it can write the file. 233 # Create temporary directory so that it can write the file.
232 os.mkdir(self._superproject._superproject_path) 234 os.mkdir(self._superproject._superproject_path)
233 update_result = self._superproject.UpdateProjectsRevisionId(projects) 235 update_result = self._superproject.UpdateProjectsRevisionId(projects, self.git_event_log)
234 self.assertIsNotNone(update_result.manifest_path) 236 self.assertIsNotNone(update_result.manifest_path)
235 self.assertFalse(update_result.fatal) 237 self.assertFalse(update_result.fatal)
236 with open(update_result.manifest_path, 'r') as fp: 238 with open(update_result.manifest_path, 'r') as fp:
@@ -256,22 +258,13 @@ class SuperprojectTestCase(unittest.TestCase):
256</manifest> 258</manifest>
257""") 259""")
258 self.maxDiff = None 260 self.maxDiff = None
259 self._superproject = git_superproject.Superproject(manifest, self.repodir, 261 self.assertIsNone(manifest.superproject)
260 self.git_event_log)
261 self.assertEqual(len(self._superproject._manifest.projects), 1)
262 projects = self._superproject._manifest.projects
263 project = projects[0]
264 project.SetRevisionId('ABCDEF')
265 update_result = self._superproject.UpdateProjectsRevisionId(projects)
266 self.assertIsNone(update_result.manifest_path)
267 self.assertFalse(update_result.fatal)
268 self.verifyErrorEvent()
269 self.assertEqual( 262 self.assertEqual(
270 sort_attributes(manifest.ToXml().toxml()), 263 sort_attributes(manifest.ToXml().toxml()),
271 '<?xml version="1.0" ?><manifest>' 264 '<?xml version="1.0" ?><manifest>'
272 '<remote fetch="http://localhost" name="default-remote"/>' 265 '<remote fetch="http://localhost" name="default-remote"/>'
273 '<default remote="default-remote" revision="refs/heads/main"/>' 266 '<default remote="default-remote" revision="refs/heads/main"/>'
274 '<project name="test-name" revision="ABCDEF" upstream="refs/heads/main"/>' 267 '<project name="test-name"/>'
275 '</manifest>') 268 '</manifest>')
276 269
277 def test_superproject_update_project_revision_id_from_local_manifest_group(self): 270 def test_superproject_update_project_revision_id_from_local_manifest_group(self):
@@ -290,8 +283,10 @@ class SuperprojectTestCase(unittest.TestCase):
290 " /></manifest> 283 " /></manifest>
291""") 284""")
292 self.maxDiff = None 285 self.maxDiff = None
293 self._superproject = git_superproject.Superproject(manifest, self.repodir, 286 self._superproject = git_superproject.Superproject(
294 self.git_event_log) 287 manifest, name='superproject',
288 remote=manifest.remotes.get('default-remote').ToRemoteSpec('superproject'),
289 revision='refs/heads/main')
295 self.assertEqual(len(self._superproject._manifest.projects), 2) 290 self.assertEqual(len(self._superproject._manifest.projects), 2)
296 projects = self._superproject._manifest.projects 291 projects = self._superproject._manifest.projects
297 data = ('160000 commit 2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea\tart\x00') 292 data = ('160000 commit 2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea\tart\x00')
@@ -302,7 +297,7 @@ class SuperprojectTestCase(unittest.TestCase):
302 return_value=data): 297 return_value=data):
303 # Create temporary directory so that it can write the file. 298 # Create temporary directory so that it can write the file.
304 os.mkdir(self._superproject._superproject_path) 299 os.mkdir(self._superproject._superproject_path)
305 update_result = self._superproject.UpdateProjectsRevisionId(projects) 300 update_result = self._superproject.UpdateProjectsRevisionId(projects, self.git_event_log)
306 self.assertIsNotNone(update_result.manifest_path) 301 self.assertIsNotNone(update_result.manifest_path)
307 self.assertFalse(update_result.fatal) 302 self.assertFalse(update_result.fatal)
308 with open(update_result.manifest_path, 'r') as fp: 303 with open(update_result.manifest_path, 'r') as fp:
@@ -337,8 +332,10 @@ class SuperprojectTestCase(unittest.TestCase):
337 " /></manifest> 332 " /></manifest>
338""") 333""")
339 self.maxDiff = None 334 self.maxDiff = None
340 self._superproject = git_superproject.Superproject(manifest, self.repodir, 335 self._superproject = git_superproject.Superproject(
341 self.git_event_log) 336 manifest, name='superproject',
337 remote=manifest.remotes.get('default-remote').ToRemoteSpec('superproject'),
338 revision='refs/heads/main')
342 self.assertEqual(len(self._superproject._manifest.projects), 3) 339 self.assertEqual(len(self._superproject._manifest.projects), 3)
343 projects = self._superproject._manifest.projects 340 projects = self._superproject._manifest.projects
344 data = ('160000 commit 2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea\tart\x00' 341 data = ('160000 commit 2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea\tart\x00'
@@ -350,7 +347,7 @@ class SuperprojectTestCase(unittest.TestCase):
350 return_value=data): 347 return_value=data):
351 # Create temporary directory so that it can write the file. 348 # Create temporary directory so that it can write the file.
352 os.mkdir(self._superproject._superproject_path) 349 os.mkdir(self._superproject._superproject_path)
353 update_result = self._superproject.UpdateProjectsRevisionId(projects) 350 update_result = self._superproject.UpdateProjectsRevisionId(projects, self.git_event_log)
354 self.assertIsNotNone(update_result.manifest_path) 351 self.assertIsNotNone(update_result.manifest_path)
355 self.assertFalse(update_result.fatal) 352 self.assertFalse(update_result.fatal)
356 with open(update_result.manifest_path, 'r') as fp: 353 with open(update_result.manifest_path, 'r') as fp: