Exemplo n.º 1
0
    def test___ne___different(self):
        """
        BootstrapSpec != other is True when they differ.
        """
        spec = BootstrapSpec("my-env", "lxd")
        other = BootstrapSpec("my-env", "spam")

        self.assertTrue(spec != other)
Exemplo n.º 2
0
    def test___eq___different(self):
        """
        BootstrapSpec == other is False when they differ.
        """
        spec = BootstrapSpec("my-env", "lxd")
        other = BootstrapSpec("my-env", "spam")

        self.assertFalse(spec == other)
Exemplo n.º 3
0
    def test___ne___same(self):
        """
        BootstrapSpec != other is False when they are the same.
        """
        spec = BootstrapSpec("my-env", "lxd")
        other = BootstrapSpec("my-env", "lxd")

        self.assertFalse(spec != other)
Exemplo n.º 4
0
    def test___eq___same_with_base_class(self):
        """
        BootstrapSpec == other is True when they are the same
        and have the same class.
        """
        spec = BootstrapSpec("my-env", "lxd")
        other = BootstrapSpec("my-env", "lxd")

        self.assertTrue(spec == other)
Exemplo n.º 5
0
    def test___eq___identity(self):
        """
        For BootstrapSpec, spec == spec is True.
        """
        spec = BootstrapSpec("my-env", "lxd")

        self.assertTrue(spec == spec)
Exemplo n.º 6
0
    def test_bootstrap_full(self):
        spec = BootstrapSpec("spam", "lxd")
        self.cli.bootstrap(spec, "0", "bootstrap.yaml", True, True, True)

        self.assert_called(
            "bootstrap -v --to 0 --auto-upgrade --config bootstrap.yaml lxd spam"
        )
Exemplo n.º 7
0
    def test_config(self):
        """
        BootstrapSpec.config() returns a Config containing
        a ControllerConfig corresponding to the bootstrap spec.
        """
        spec = BootstrapSpec("my-env", "lxd", "xenial", "pw")
        cfg = spec.config()

        self.assertEqual(len(cfg.controllers), 1)
        self.assertEqual(
            cfg.controllers[0],
            config.ControllerConfig(
                "my-env",
                config.CloudConfig("lxd", "lxd"),
                config.BootstrapConfig("xenial", "pw"),
            ),
        )
Exemplo n.º 8
0
    def test___eq___same_with_sub_class(self):
        """
        BootstrapSpec == other is True when they are the same,
        even if the other is a BootstrapSpec subclass.
        """
        spec = BootstrapSpec("my-env", "lxd")
        other = type("SubSpec", (BootstrapSpec, ), {})("my-env", "lxd")

        self.assertTrue(spec == other)
Exemplo n.º 9
0
 def test_repr_full(self):
     """
     The repr of BootstrapSpec is correct.
     """
     spec = BootstrapSpec("my-env", "lxd", "xenial", "pw")
     self.assertEqual(
         repr(spec),
         ("BootstrapSpec(name='my-env', driver='lxd', "
          "default_series='xenial', admin_secret='pw')"),
     )
Exemplo n.º 10
0
 def test_repr_minimal(self):
     """
     The repr of BootstrapSpec is correct even if some fields are missing.
     """
     spec = BootstrapSpec("my-env", "lxd")
     self.assertEqual(
         repr(spec),
         ("BootstrapSpec(name='my-env', driver='lxd', "
          "default_series='trusty', admin_secret=None)"),
     )
Exemplo n.º 11
0
    def test_full(self):
        """
        BootstrapSpec() works when all args are provided.
        """
        spec = BootstrapSpec("my-env", "lxd", "xenial", "pw")

        self.assertEqual(spec.name, "my-env")
        self.assertEqual(spec.driver, "lxd")
        self.assertEqual(spec.default_series, "xenial")
        self.assertEqual(spec.admin_secret, "pw")
Exemplo n.º 12
0
    def test_minimal(self):
        """
        BootstrapSpec() works with minimal args.
        """
        spec = BootstrapSpec("my-env", "lxd")

        self.assertEqual(spec.name, "my-env")
        self.assertEqual(spec.driver, "lxd")
        self.assertEqual(spec.default_series, "trusty")
        self.assertIsNone(spec.admin_secret)
Exemplo n.º 13
0
    def test___eq___same_with_other_class(self):
        """
        BootstrapSpec == other is True when they are the same,
        even if the classes are different.
        """
        spec = BootstrapSpec("my-env", "lxd", "trusty", "pw")
        other_cls = namedtuple("Sub",
                               "name driver default_series admin_secret")
        other = other_cls("my-env", "lxd", "trusty", "pw")

        self.assertTrue(spec == other)
Exemplo n.º 14
0
    def test_bootstrap_minimal(self):
        self.version_cli.return_get_bootstrap_args = ["sub"]
        cli = CLI(self.exe, self.version_cli)
        spec = BootstrapSpec("spam", "lxd")
        cli.bootstrap(spec)

        self.assertEqual(self.calls, [
            ("get_bootstrap_args",
             (spec, None, None, False, False, False), {}),
            ("run", ("sub", ), {}),
        ])
Exemplo n.º 15
0
    def test_bootstrap_full(self):
        self.version_cli.return_get_bootstrap_args = ["sub"]
        cli = CLI(self.exe, self.version_cli)
        spec = BootstrapSpec("spam", "lxd")
        cli.bootstrap(spec, "0", "bootstrap.yaml", True, True, True)

        self.assertEqual(self.calls, [
            ("get_bootstrap_args",
             (spec, "0", "bootstrap.yaml", True, True, True), {}),
            ("run", ("sub", ), {}),
        ])
Exemplo n.º 16
0
    def test_bootstrap_minimal(self):
        spec = BootstrapSpec("spam", "lxd")
        self.cli.bootstrap(spec)

        self.assert_called("bootstrap --no-gui lxd spam")
Exemplo n.º 17
0
    def test_bootstrap_full(self):
        spec = BootstrapSpec("spam", "lxd")
        self.cli.bootstrap(spec, "0", None, True, True, True)

        self.assert_called("bootstrap -v --to 0 -e spam")