@@ -104,7 +104,7 @@ def test_create_migration_payload_includes_optional_fields(self):
104104 validate_only = True ,
105105 cutover_date = '2030-12-31T11:59:00Z' ,
106106 agent_pool = 'MigrationPool' ,
107- skip_validation = 'ActivePullRequestCount,PullRequestDeltaSize' ,
107+ skip_validation = 2147483647 ,
108108 organization = self ._TEST_ORG ,
109109 detect = False
110110 )
@@ -113,7 +113,7 @@ def test_create_migration_payload_includes_optional_fields(self):
113113 self .assertTrue (payload ['validateOnly' ])
114114 self .assertEqual (payload ['scheduledCutoverDate' ], '2030-12-31T11:59:00Z' )
115115 self .assertEqual (payload ['agentPoolName' ], 'MigrationPool' )
116- self .assertEqual (payload ['skipValidation' ], 'ActivePullRequestCount,PullRequestDeltaSize' )
116+ self .assertEqual (payload ['skipValidation' ], 2147483647 )
117117
118118 def test_create_migration_empty_agent_pool_omitted (self ):
119119 with patch ('azext_devops.dev.migration.migration.resolve_instance' ) as mock_resolve , \
@@ -134,7 +134,7 @@ def test_create_migration_empty_agent_pool_omitted(self):
134134 payload = mock_send .call_args [0 ][3 ]
135135 self .assertNotIn ('agentPoolName' , payload )
136136
137- def test_create_migration_omits_empty_skip_validation (self ):
137+ def test_create_migration_omits_none_skip_validation (self ):
138138 with patch ('azext_devops.dev.migration.migration.resolve_instance' ) as mock_resolve , \
139139 patch ('azext_devops.dev.migration.migration._get_service_client' ) as mock_client , \
140140 patch ('azext_devops.dev.migration.migration._send_request' ) as mock_send :
@@ -146,15 +146,15 @@ def test_create_migration_omits_empty_skip_validation(self):
146146 target_repository = 'https://example.ghe.com/OrgName/RepoName' ,
147147 target_owner_user_id = 'GeoffCoxMSFT' ,
148148 agent_pool = 'MigrationPool' ,
149- skip_validation = ' ' ,
149+ skip_validation = None ,
150150 organization = self ._TEST_ORG ,
151151 detect = False
152152 )
153153
154154 payload = mock_send .call_args [0 ][3 ]
155155 self .assertNotIn ('skipValidation' , payload )
156156
157- def test_create_migration_trims_optional_fields (self ):
157+ def test_create_migration_trims_agent_pool (self ):
158158 with patch ('azext_devops.dev.migration.migration.resolve_instance' ) as mock_resolve , \
159159 patch ('azext_devops.dev.migration.migration._get_service_client' ) as mock_client , \
160160 patch ('azext_devops.dev.migration.migration._send_request' ) as mock_send :
@@ -166,14 +166,14 @@ def test_create_migration_trims_optional_fields(self):
166166 target_repository = 'https://example.ghe.com/OrgName/RepoName' ,
167167 target_owner_user_id = 'GeoffCoxMSFT' ,
168168 agent_pool = ' MigrationPool ' ,
169- skip_validation = ' ActivePullRequestCount, PullRequestDeltaSize ' ,
169+ skip_validation = 42 ,
170170 organization = self ._TEST_ORG ,
171171 detect = False
172172 )
173173
174174 payload = mock_send .call_args [0 ][3 ]
175175 self .assertEqual (payload ['agentPoolName' ], 'MigrationPool' )
176- self .assertEqual (payload ['skipValidation' ], 'ActivePullRequestCount, PullRequestDeltaSize' )
176+ self .assertEqual (payload ['skipValidation' ], 42 )
177177
178178 def test_create_migration_passes_target_repository_to_api (self ):
179179 with patch ('azext_devops.dev.migration.migration.resolve_instance' ) as mock_resolve , \
@@ -281,7 +281,7 @@ def test_resume_sets_validate_only(self):
281281 patch ('azext_devops.dev.migration.migration._get_service_client' ) as mock_client , \
282282 patch ('azext_devops.dev.migration.migration._send_request' ) as mock_send :
283283 mock_send .return_value = {}
284- mock_get .return_value = {'status' : 'succeeded ' }
284+ mock_get .return_value = {'status' : 'suspended ' }
285285 mock_resolve .return_value = self ._TEST_ORG
286286
287287 resume_migration (repository_id = '00000000-0000-0000-0000-000000000000' ,
@@ -325,6 +325,80 @@ def test_resume_without_flags_preserves_mode(self):
325325 self .assertNotIn ('validateOnly' , payload )
326326 self .assertEqual (payload ['statusRequested' ], 'active' )
327327
328+ def test_resume_migration_promotes_validate_only_succeeded (self ):
329+ with patch ('azext_devops.dev.migration.migration.get_migration' ) as mock_get , \
330+ patch ('azext_devops.dev.migration.migration.resolve_instance' ) as mock_resolve , \
331+ patch ('azext_devops.dev.migration.migration._get_service_client' ) as mock_client , \
332+ patch ('azext_devops.dev.migration.migration._send_request' ) as mock_send :
333+ mock_send .return_value = {}
334+ mock_get .return_value = {
335+ 'status' : 'succeeded' ,
336+ 'validateOnly' : True ,
337+ 'targetRepository' : 'https://ghe.example.com/org/repo' ,
338+ 'targetOwnerUserId' : 'testuser' ,
339+ 'agentPoolName' : 'MyPool' ,
340+ 'scheduledCutoverDate' : '2030-06-01T00:00:00Z' ,
341+ }
342+ mock_resolve .return_value = self ._TEST_ORG
343+
344+ resume_migration (repository_id = '00000000-0000-0000-0000-000000000000' ,
345+ migration = True ,
346+ organization = self ._TEST_ORG , detect = False )
347+
348+ args = mock_send .call_args [0 ]
349+ self .assertEqual (args [1 ], 'POST' )
350+ payload = args [3 ]
351+ self .assertFalse (payload ['validateOnly' ])
352+ self .assertEqual (payload ['skipValidation' ], 2147483647 )
353+ self .assertEqual (payload ['targetRepository' ], 'https://ghe.example.com/org/repo' )
354+ self .assertEqual (payload ['targetOwnerUserId' ], 'testuser' )
355+ self .assertEqual (payload ['agentPoolName' ], 'MyPool' )
356+ self .assertEqual (payload ['scheduledCutoverDate' ], '2030-06-01T00:00:00Z' )
357+
358+ def test_resume_migration_promote_omits_null_optional_fields (self ):
359+ with patch ('azext_devops.dev.migration.migration.get_migration' ) as mock_get , \
360+ patch ('azext_devops.dev.migration.migration.resolve_instance' ) as mock_resolve , \
361+ patch ('azext_devops.dev.migration.migration._get_service_client' ) as mock_client , \
362+ patch ('azext_devops.dev.migration.migration._send_request' ) as mock_send :
363+ mock_send .return_value = {}
364+ mock_get .return_value = {
365+ 'status' : 'succeeded' ,
366+ 'validateOnly' : True ,
367+ 'targetRepository' : 'https://ghe.example.com/org/repo' ,
368+ 'targetOwnerUserId' : 'testuser' ,
369+ }
370+ mock_resolve .return_value = self ._TEST_ORG
371+
372+ resume_migration (repository_id = '00000000-0000-0000-0000-000000000000' ,
373+ migration = True ,
374+ organization = self ._TEST_ORG , detect = False )
375+
376+ payload = mock_send .call_args [0 ][3 ]
377+ self .assertNotIn ('agentPoolName' , payload )
378+ self .assertNotIn ('scheduledCutoverDate' , payload )
379+
380+ def test_resume_succeeded_without_migration_flag_errors (self ):
381+ with patch ('azext_devops.dev.migration.migration.get_migration' ) as mock_get , \
382+ patch ('azext_devops.dev.migration.migration.resolve_instance' ) as mock_resolve :
383+ mock_get .return_value = {'status' : 'succeeded' , 'validateOnly' : True }
384+ mock_resolve .return_value = self ._TEST_ORG
385+
386+ with self .assertRaises (CLIError ) as ctx :
387+ resume_migration (repository_id = '00000000-0000-0000-0000-000000000000' ,
388+ organization = self ._TEST_ORG , detect = False )
389+ self .assertIn ('--migration' , str (ctx .exception ))
390+
391+ def test_resume_succeeded_full_migration_errors (self ):
392+ with patch ('azext_devops.dev.migration.migration.get_migration' ) as mock_get , \
393+ patch ('azext_devops.dev.migration.migration.resolve_instance' ) as mock_resolve :
394+ mock_get .return_value = {'status' : 'succeeded' , 'validateOnly' : False }
395+ mock_resolve .return_value = self ._TEST_ORG
396+
397+ with self .assertRaises (CLIError ) as ctx :
398+ resume_migration (repository_id = '00000000-0000-0000-0000-000000000000' ,
399+ organization = self ._TEST_ORG , detect = False )
400+ self .assertIn ('abandon' , str (ctx .exception ))
401+
328402
329403if __name__ == '__main__' :
330404 unittest .main ()
0 commit comments