示例#1
0
 def test_parseNonASCIIConfig(self):
     """
     Non-ASCII <string>s found as part of a configuration file will be
     retrieved as UTF-8 encoded 'str' objects, as parsed by
     L{NoUnicodePlistParser}.
     """
     cfg = Config(PListConfigProvider({"DataRoot": ""}))
     tempfile = FilePath(self.mktemp())
     tempfile.setContent(nonASCIIConfigPList)
     cfg.load(tempfile.path)
     self.assertEquals(cfg.DataRoot, nonASCIIValue)
示例#2
0
    def test_includes(self):

        plist1 = """
<plist version="1.0">
  <dict>
    <key>ServerRoot</key>
    <string>/root</string>
    <key>DocumentRoot</key>
    <string>defaultdoc</string>
    <key>DataRoot</key>
    <string>defaultdata</string>
    <key>ConfigRoot</key>
    <string>defaultconfig</string>
    <key>LogRoot</key>
    <string>defaultlog</string>
    <key>RunRoot</key>
    <string>defaultrun</string>
    <key>Includes</key>
    <array>
        <string>%s</string>
    </array>
  </dict>
</plist>
"""

        plist2 = """
<plist version="1.0">
  <dict>
    <key>DataRoot</key>
    <string>overridedata</string>
  </dict>
</plist>
"""

        tempfile2 = FilePath(self.mktemp())
        tempfile2.setContent(plist2)

        tempfile1 = FilePath(self.mktemp())
        tempfile1.setContent(plist1 % (tempfile2.path, ))

        cfg = Config(
            PListConfigProvider({
                "ServerRoot": "",
                "DocumentRoot": "",
                "DataRoot": "",
                "ConfigRoot": "",
                "LogRoot": "",
                "RunRoot": "",
                "Includes": [],
            }))
        cfg.addPostUpdateHooks([_updateDataStore])
        cfg.load(tempfile1.path)
        self.assertEquals(cfg.DocumentRoot, "/root/overridedata/defaultdoc")
        self.assertEquals(cfg.DataRoot, "/root/overridedata")
示例#3
0
 def test_relativeDefaultPaths(self):
     """
     The paths specified in the default configuration should be interpreted
     as relative to the paths specified in the configuration file.
     """
     cfg = Config(PListConfigProvider(
         {"AccountingLogRoot": "some-path",
          "LogRoot": "should-be-ignored"}))
     cfg.addPostUpdateHooks([_updateDataStore])
     tempfile = FilePath(self.mktemp())
     tempfile.setContent("<plist version='1.0'><dict>"
                         "<key>LogRoot</key><string>/some/root</string>"
                         "</dict></plist>")
     cfg.load(tempfile.path)
     self.assertEquals(cfg.AccountingLogRoot, "/some/root/some-path")
     tempfile.setContent("<plist version='1.0'><dict>"
                         "<key>LogRoot</key><string>/other/root</string>"
                         "</dict></plist>")
     cfg.load(tempfile.path)
     self.assertEquals(cfg.AccountingLogRoot, "/other/root/some-path")