| ... | ... | @@ -268,6 +268,24 @@ class GuestCancellation(unittest.TestCase): |
| 268 | 268 | self.assertEqual(computer.handle('fixture', {'action':'status'})['readiness'], 'ready') |
| 269 | 269 | work.assert_called_once_with('fixture', 'macos', {'action':'status'}) |
| 270 | 270 | |
| 271 | def test_windows_status_waits_for_personalization_before_using_template_session(self): |
| 272 | root = '<domain><metadata><vm xmlns="https://paperclover.net/snowglobe"><platform>windows</platform><setup>windows-v4</setup></vm></metadata></domain>' |
| 273 | with patch.object(computer.vms, 'virsh', side_effect=lambda action, *a, **k: 'running' if action == 'domstate' else root), \ |
| 274 | patch.object(computer, 'qga', return_value={'supported_commands':[{'name':'guest-exec','enabled':True}]}), \ |
| 275 | patch.object(computer.vms, 'windows_setup') as setup, patch.object(computer, 'worker') as work: |
| 276 | for phase in ['starting', 'personalizing', 'signingIn', 'failed']: |
| 277 | setup.return_value = phase |
| 278 | status = computer.handle('fixture', {'action':'status'}) |
| 279 | self.assertEqual(status['readiness'], 'setup_failed' if phase == 'failed' else 'personalizing') |
| 280 | self.assertEqual(status['setup'], phase) |
| 281 | self.assertEqual(status['capabilities'], ['shot', 'input']) |
| 282 | work.assert_not_called() |
| 283 | setup.return_value = 'ready' |
| 284 | work.return_value = {'execution_context':{'user':'fixture'}} |
| 285 | status = computer.handle('fixture', {'action':'status'}) |
| 286 | self.assertEqual(status['readiness'], 'ready') |
| 287 | self.assertEqual(status['execution_context']['user'], 'fixture') |
| 288 | |
| 271 | 289 | def test_failed_cleanup_keeps_status_available_and_blocks_later_control(self): |
| 272 | 290 | for platform, identity in [('linux', 'snowglobe-computer-request-' + 'a' * 32), ('windows', 'a' * 32)]: |
| 273 | 291 | operation = {'platform': platform, 'id': identity} |