Ejemplo n.º 1
0
    def test_service_connect_list_global_keychain(self):
        multi_cmd = cci.ConnectServiceCommand()
        config = mock.Mock()
        config.is_global_keychain = True
        config.global_config.services = {"test": {}}
        ctx = mock.Mock()

        with mock.patch("cumulusci.cli.cci.TEST_CONFIG", config):
            result = multi_cmd.list_commands(ctx)
        self.assertEqual(["test"], result)
Ejemplo n.º 2
0
    def test_service_connect_invalid_service(self):
        multi_cmd = cci.ConnectServiceCommand()
        ctx = mock.Mock()
        config = mock.MagicMock()
        config.is_global_keychain = False
        config.project_config.services = {}

        with mock.patch("cumulusci.cli.cci.TEST_CONFIG", config):
            with self.assertRaises(click.UsageError):
                multi_cmd.get_command(ctx, "test")
Ejemplo n.º 3
0
    def test_service_connect(self):
        multi_cmd = cci.ConnectServiceCommand()
        config = mock.Mock()
        config.project_config.services__test__attributes = {"attr": {"required": False}}
        ctx = mock.Mock()
        ctx.ensure_object.return_value = config

        cmd = multi_cmd.get_command(ctx, "test")
        run_click_command(cmd, project=True)

        config.keychain.set_service.assert_called_once()

        run_click_command(cmd, project=False)
Ejemplo n.º 4
0
    def test_service_connect_global_keychain(self):
        multi_cmd = cci.ConnectServiceCommand()
        ctx = mock.Mock()
        config = mock.MagicMock()
        config.is_global_keychain = True
        config.global_config.services = {
            "test": {"attributes": {"attr": {"required": False}}}
        }

        with mock.patch("cumulusci.cli.cci.TEST_CONFIG", config):
            cmd = multi_cmd.get_command(ctx, "test")
            run_click_command(cmd, project=True)

        config.keychain.set_service.assert_called_once()

        run_click_command(cmd, project=False)
Ejemplo n.º 5
0
    def test_service_connect_validator(self):
        multi_cmd = cci.ConnectServiceCommand()
        ctx = mock.Mock()
        config = mock.MagicMock()
        config.project_config.services__test = {
            "attributes": {},
            "validator": "cumulusci.cli.tests.test_cci.validate_service",
        }

        with mock.patch("cumulusci.cli.cci.TEST_CONFIG", config):
            cmd = multi_cmd.get_command(ctx, "test")
            try:
                run_click_command(cmd, project=True)
            except click.UsageError as e:
                self.assertEqual("Validation failed", str(e))
            else:
                self.fail("Did not raise expected click.UsageError")