~frankban/juju-quickstart/envs-backup

« back to all changes in this revision

Viewing changes to quickstart/tests/test_app.py

  • Committer: Francesco Banconi
  • Date: 2014-01-08 21:25:36 UTC
  • Revision ID: francesco.banconi@canonical.com-20140108212536-ylihhb7su8a41rcl
Checkpoint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
377
377
 
378
378
 
379
379
@helpers.mock_print
380
 
class TestEnsureEnvironments(
381
 
        helpers.CallTestsMixin, ProgramExitTestsMixin, unittest.TestCase):
382
 
 
383
 
    def test_inits(self, mock_print):
384
 
        side_effects = (
385
 
            (0, '', ''),
386
 
            (0, '', ''),
387
 
        )
388
 
        with self.patch_multiple_calls(side_effects):
389
 
            self.assertEqual(app.ensure_environments(), 'local')
390
 
            mock_print.assert_has_calls([
391
 
                mock.call('environments file not found; running juju init'),
392
 
                mock.call('defaulting to local environment for a new '
393
 
                          'environments file')
394
 
            ])
395
 
 
396
 
    def test_failure(self, mock_print):
397
 
        side_effects = (
398
 
            (1, '', 'Error!'),  # Fail on init.
399
 
            (0, '', ''),
400
 
        )
401
 
        with self.assert_program_exit('Error!'):
402
 
            with self.patch_multiple_calls(side_effects):
403
 
                app.ensure_environments()
404
 
        side_effects = (
405
 
            (0, '', ''),
406
 
            (1, '', 'Error!'),  # Fail on switch.
407
 
        )
408
 
        with self.assert_program_exit('Error!'):
409
 
            with self.patch_multiple_calls(side_effects):
410
 
                app.ensure_environments()
411
 
 
412
 
 
413
 
@helpers.mock_print
414
380
class TestBootstrap(
415
381
        helpers.CallTestsMixin, ProgramExitTestsMixin, unittest.TestCase):
416
382