def test_multiple_dicts(self):
        expected = """\
        vars.http_vhosts["Syncthing https redirect"] = {
            http_port = 8384
            http_expect = 302
        }
        vars.http_vhosts["Syncthing"] = {
            http_port = 8384
            http_expect = 401
            http_ssl = 1
        }
        """

        configuration = {
            "http_vhosts": {
                "Syncthing https redirect": {
                    "http_port": 8384,
                    "http_expect": 302
                },
                "Syncthing": {
                    "http_port": 8384,
                    "http_ssl": 1,
                    "http_expect": 401
                }
            }
        }

        self.assertEquals(self._p(expected), to_icinga2.to_icinga2_expression(configuration))
 def test_multiple_values(self):
     expected = """
     vars.smtp = 1
     vars.os_family = "RedHat"
     vars.os = "Linux"
     """
     self.assertEqual(self._p(expected), to_icinga2.to_icinga2_expression(dict(os="Linux", os_family="RedHat", smtp=1)))
    def test_empty_dict(self):
        expected = """
        vars.disks["disk"] = {

        }
        """
        self.assertEqual(self._p(expected), to_icinga2.to_icinga2_expression({
            "disks": {"disk": {}}
        }))
    def test_with_list(self):
        expected = """
        vars.notification["mail"] = {
            groups = [ "icingaadmins" ]
        }
        """

        self.assertEqual(self._p(expected), to_icinga2.to_icinga2_expression({
            "notification": {
                "mail": {
                    "groups": ["icingaadmins"]
                }
            }
        }))
    def test_nested_dict(self):
        expected = dedent("""\
        vars.http_vhosts["Default page"] = {
            http_string = "the string"
            http_port = 8384
            http_uri = "/"
        }""")
        configuration = {
            "http_vhosts": {
                "Default page": {
                    "http_string": "the string",
                    "http_uri": "/",
                    "http_port": 8384
                }
            }
        }


        self.assertEqual(expected, to_icinga2.to_icinga2_expression(configuration))
 def test_string_value(self):
     self.assertEqual("vars.os = \"Linux\"", to_icinga2.to_icinga2_expression(dict(os="Linux")))