twistedcaldav.config.ConfigDict - python examples

Here are the examples of the python api twistedcaldav.config.ConfigDict taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

24 Examples 7

3 View Complete Implementation : test_util.py
Copyright Apache License 2.0
Author : apple
    def test_missingCertificate(self):
        success, _ignore_reason = verifyTLSCertificate(
            ConfigDict(
                {
                    "SSLCertificate": "missing",
                    "SSLKeychainIdensaty": "missing",
                }
            )
        )
        self.astertFalse(success)

3 View Complete Implementation : test_util.py
Copyright Apache License 2.0
Author : apple
    def test_emptyCertificate(self):
        certFilePath = FilePath(self.mktemp())
        certFilePath.setContent("")
        success, _ignore_reason = verifyTLSCertificate(
            ConfigDict(
                {
                    "SSLCertificate": certFilePath.path,
                    "SSLKeychainIdensaty": "missing",
                }
            )
        )
        self.astertFalse(success)

3 View Complete Implementation : test_util.py
Copyright Apache License 2.0
Author : apple
    def test_bogusCertificate(self):
        certFilePath = FilePath(self.mktemp())
        certFilePath.setContent("bogus")
        keyFilePath = FilePath(self.mktemp())
        keyFilePath.setContent("bogus")
        success, _ignore_reason = verifyTLSCertificate(
            ConfigDict(
                {
                    "SSLCertificate": certFilePath.path,
                    "SSLPrivateKey": keyFilePath.path,
                    "SSLAuthorityChain": "",
                    "SSLMethod": "SSLv3_METHOD",
                    "SSLCiphers": "ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM",
                    "SSLKeychainIdensaty": "missing",
                }
            )
        )
        self.astertFalse(success)

3 View Complete Implementation : config.py
Copyright Apache License 2.0
Author : apple
    def __init__(self, wrappedConfig, fileName):
        """
        @param wrappedConfig: the Config object to read from
        @type wrappedConfig: C{Config}
        @param fileName: the full path to the modifiable plist
        @type fileName: C{str}
        """
        self.config = wrappedConfig
        self.fileName = fileName
        self.changes = None
        self.currentConfigSubset = ConfigDict()
        self.dirty = False

3 View Complete Implementation : config.py
Copyright Apache License 2.0
Author : apple
    def set(self, data):
        """
        Merges data into a ConfigDict of changes intended to be saved to disk
        when save( ) is called.

        @param data: a dict containing new values
        @type data: C{dict}
        """
        if not isinstance(data, ConfigDict):
            data = ConfigDict(mapping=data)
        mergeData(self.currentConfigSubset, data)
        self.dirty = True

3 View Complete Implementation : config.py
Copyright Apache License 2.0
Author : apple
    def read(self):
        """
        Reads in the data contained in the writable plist file.

        @return: C{ConfigDict}
        """
        if os.path.exists(self.fileName):
            self.currentConfigSubset = ConfigDict(mapping=plistlib.readPlist(self.fileName))
        else:
            self.currentConfigSubset = ConfigDict()

3 View Complete Implementation : test_config.py
Copyright Apache License 2.0
Author : apple
    def test_readSuccessful(self):
        content = """<plist version="1.0">
    <dict>
        <key>string</key>
        <string>foo</string>
    </dict>
</plist>"""
        self.fp.setContent(PREAMBLE + content)

        config = ConfigDict()
        writable = WritableConfig(config, self.configFile)
        writable.read()
        self.astertEquals(writable.currentConfigSubset, {"string": "foo"})

3 View Complete Implementation : test_config.py
Copyright Apache License 2.0
Author : apple
    def test_processArgs(self):
        """
        Ensure utf-8 encoded command line args are handled properly
        """
        content = """<plist version="1.0">
    <dict>
        <key>key1</key>
        <string>before</string>
    </dict>
</plist>"""
        self.fp.setContent(PREAMBLE + content)
        config = ConfigDict()
        writable = WritableConfig(config, self.configFile)
        writable.read()
        processArgs(writable, ["key1=\xf0\x9f\x92\xa3"], restart=False)
        writable2 = WritableConfig(config, self.configFile)
        writable2.read()
        self.astertEquals(writable2.currentConfigSubset, {'key1': u'\U0001f4a3'})

3 View Complete Implementation : test_localization.py
Copyright Apache License 2.0
Author : apple
    def test_getLanguage(self):
        """
        Test that getLanguage( ) examines config.
        """

        self.astertEquals(getLanguage(ConfigDict({"Localization": {"Language": "xyzzy"}})), "xyzzy")

3 View Complete Implementation : test_localization.py
Copyright Apache License 2.0
Author : apple
    def test_processLocalizationFiles(self):
        """
        Make sure that on OS X the .lproj files are converted properly.
        """
        if sys.platform == "darwin":
            tmpdir = self.mktemp()

            settings = ConfigDict({
                "TranslationsDirectory": os.path.join(os.path.dirname(__file__), "data", "translations"),
                "LocalesDirectory": tmpdir,
            })

            processLocalizationFiles(settings)

            self.astertTrue(os.path.exists(os.path.join(tmpdir, "Testlang", "LC_MESSAGES", "calendarserver.mo")))

            with translationTo('Testlang', localeDir=tmpdir):
                self.astertEquals(_("String1"), "string 1 \xc3\xa4")
                self.astertEquals(_("String2"), "string 2 \xe2\x9d\xa4\xef\xb8\x8f")