~veebers/juju-ci-tools/perf-initial-heatmap-details

« back to all changes in this revision

Viewing changes to tests/test_assess_container_networking.py

  • Committer: Martin Packman
  • Date: 2016-02-11 15:22:35 UTC
  • mto: This revision was merged to the branch mainline in revision 1264.
  • Revision ID: martin.packman@canonical.com-20160211152235-wyktd2amfyoxbb0e
Refactor how juju feature flags are handled with new enable_feature method

Show diffs side-by-side

added added

removed removed

Lines of Context:
422
422
 
423
423
    def test_bootstrap_required(self):
424
424
        argv = ["an-env", "/bin/juju", "/tmp/logs", "an-env-mod", "--verbose"]
425
 
        client = Mock(spec=["bootstrap", "enable_container_address_allocation",
426
 
                            "is_jes_enabled"])
 
425
        client = Mock(spec=["bootstrap", "enable_feature", "is_jes_enabled"])
427
426
        with patch("assess_container_networking.assess_container_networking",
428
427
                   autospec=True) as mock_assess:
429
428
            with self.patch_bootstrap_manager() as mock_bc:
430
429
                with self.patch_main(argv, client, logging.DEBUG):
431
430
                    ret = jcnet.main(argv)
432
 
        client.enable_container_address_allocation.assert_called_once_with()
 
431
        client.enable_feature.assert_called_once_with('address-allocation')
433
432
        client.bootstrap.assert_called_once_with(False)
434
433
        self.assertEqual("", self.log_stream.getvalue())
435
434
        self.assertEqual(mock_bc.call_count, 1)
439
438
    def test_clean_existing_env(self):
440
439
        argv = ["an-env", "/bin/juju", "/tmp/logs", "an-env-mod",
441
440
                "--clean-environment"]
442
 
        client = Mock(spec=["enable_container_address_allocation", "env",
443
 
                            "get_status", "is_jes_enabled", "wait_for",
444
 
                            "wait_for_started"])
 
441
        client = Mock(spec=["enable_feature", "env", "get_status",
 
442
                            "is_jes_enabled", "wait_for", "wait_for_started"])
445
443
        client.get_status.return_value = Status.from_text("""
446
444
            machines:
447
445
                "0":
452
450
            with self.patch_bootstrap_manager() as mock_bc:
453
451
                with self.patch_main(argv, client, logging.INFO):
454
452
                    ret = jcnet.main(argv)
455
 
        client.enable_container_address_allocation.assert_called_once_with()
 
453
        client.enable_feature.assert_called_once_with('address-allocation')
456
454
        self.assertEqual(client.env.environment, "an-env-mod")
457
455
        self.assertEqual("", self.log_stream.getvalue())
458
456
        self.assertEqual(mock_bc.call_count, 0)
462
460
    def test_clean_missing_env(self):
463
461
        argv = ["an-env", "/bin/juju", "/tmp/logs", "an-env-mod",
464
462
                "--clean-environment"]
465
 
        client = Mock(spec=["bootstrap", "enable_container_address_allocation",
466
 
                            "env", "get_status", "is_jes_enabled", "wait_for",
467
 
                            "wait_for_started"])
 
463
        client = Mock(spec=["bootstrap", "enable_feature", "env", "get_status",
 
464
                            "is_jes_enabled", "wait_for", "wait_for_started"])
468
465
        client.get_status.side_effect = [
469
466
            Exception("Timeout"),
470
467
            Status.from_text("""
478
475
            with self.patch_bootstrap_manager() as mock_bc:
479
476
                with self.patch_main(argv, client, logging.INFO):
480
477
                    ret = jcnet.main(argv)
481
 
        client.enable_container_address_allocation.assert_called_once_with()
 
478
        client.enable_feature.assert_called_once_with('address-allocation')
482
479
        self.assertEqual(client.env.environment, "an-env-mod")
483
480
        client.bootstrap.assert_called_once_with(False)
484
481
        self.assertEqual(
491
488
    def test_final_clean_fails(self):
492
489
        argv = ["an-env", "/bin/juju", "/tmp/logs", "an-env-mod",
493
490
                "--clean-environment"]
494
 
        client = Mock(spec=["enable_container_address_allocation", "env",
495
 
                            "get_status", "is_jes_enabled", "wait_for",
496
 
                            "wait_for_started"])
 
491
        client = Mock(spec=["enable_feature", "env", "get_status",
 
492
                            "is_jes_enabled", "wait_for", "wait_for_started"])
497
493
        client.get_status.side_effect = [
498
494
            Status.from_text("""
499
495
                machines:
507
503
            with self.patch_bootstrap_manager() as mock_bc:
508
504
                with self.patch_main(argv, client, logging.INFO):
509
505
                    ret = jcnet.main(argv)
510
 
        client.enable_container_address_allocation.assert_called_once_with()
 
506
        client.enable_feature.assert_called_once_with('address-allocation')
511
507
        self.assertEqual(client.env.environment, "an-env-mod")
512
508
        self.assertEqual(
513
509
            "INFO Could not clean existing env: Timeout\n",