コード例 #1
0
 def setUp(self):
     TestCase.setUp(self)
     self.notifier = StubNotifier()
     self.protocol = SimpleLineNotificationProtocol()
     self.protocol.notifier = self.notifier
     self.protocol.transport = StubTransport()
     self.notifier.addObserver(self.protocol)
コード例 #2
0
    def setUp(self):
        TestCase.setUp(self)
        self.memcache = InMemoryMemcacheProtocol()
        self.ccn = MemcacheChangeNotifier(StubURLResource(':memory:'),
                                          cachePool=self.memcache)

        self.ccn._newCacheToken = instancemethod(_newCacheToken, self.ccn,
                                                 MemcacheChangeNotifier)
コード例 #3
0
 def setUp(self):
     """
     Create a L{MemCachePool}.
     """
     TestCase.setUp(self)
     self.reactor = StubReactor()
     self.pool = MemCachePool(MC_ADDRESS,
                              maxClients=5,
                              reactor=self.reactor)
コード例 #4
0
    def setUp(self):
        TestCase.setUp(self)
        self.memcache = InMemoryMemcacheProtocol()
        self.ccn = MemcacheChangeNotifier(
            StubURLResource(':memory:'),
            cachePool=self.memcache)

        self.ccn._newCacheToken = instancemethod(_newCacheToken,
                                                 self.ccn,
                                                 MemcacheChangeNotifier)
コード例 #5
0
 def setUp(self):
     TestCase.setUp(self)
     self.xmlStream = StubXmlStream()
     self.settings = { "ServiceAddress" : "pubsub.example.com",
         "NodeConfiguration" : { "pubsub#deliver_payloads" : "1" },
         "HeartbeatMinutes" : 30,
     }
     self.notifier = XMPPNotifier(self.settings, reactor=Clock(),
         configOverride=self.xmppEnabledConfig, heartbeat=False)
     self.notifier.streamOpened(self.xmlStream)
コード例 #6
0
 def setUp(self):
     """
     Set up our options object, giving it a parent, and forcing the
     global config to be loaded from defaults.
     """
     TestCase.setUp(self)
     self.config = TestCalDAVOptions()
     self.config.parent = Options()
     self.config.parent["uid"] = 0
     self.config.parent["gid"] = 0
     self.config.parent["nodaemon"] = False
コード例 #7
0
    def setUp(self):
        TestCase.setUp(self)
        self.options = TestCalDAVOptions()
        self.options.parent = Options()
        self.options.parent["gid"] = None
        self.options.parent["uid"] = None
        self.options.parent["nodaemon"] = None

        self.config = ConfigDict(DEFAULT_CONFIG)

        accountsFile = os.path.join(sourceRoot, "twistedcaldav/directory/test/accounts.xml")
        resourcesFile = os.path.join(sourceRoot, "twistedcaldav/directory/test/resources.xml")
        augmentsFile = os.path.join(sourceRoot, "twistedcaldav/directory/test/augments.xml")
        pemFile = os.path.join(sourceRoot, "twistedcaldav/test/data/server.pem")

        self.config["DirectoryService"] = {
            "params": {"xmlFile": accountsFile},
            "type": "twistedcaldav.directory.xmlfile.XMLDirectoryService"
        }

        self.config["ResourceService"] = {
            "params": {"xmlFile": resourcesFile},
        }

        self.config["AugmentService"] = {
            "params": {"xmlFiles": [augmentsFile]},
            "type": "twistedcaldav.directory.augment.AugmentXMLDB"
        }

        self.config.UseDatabase    = False
        self.config.ServerRoot     = self.mktemp()
        self.config.ConfigRoot     = "config"
        self.config.ProcessType    = "Single"
        self.config.SSLPrivateKey  = pemFile
        self.config.SSLCertificate = pemFile
        self.config.EnableSSL      = True
        self.config.Memcached.Pools.Default.ClientEnabled = False
        self.config.Memcached.Pools.Default.ServerEnabled = False
        self.config.DirectoryAddressBook.Enabled = False

        self.config.SudoersFile = ""

        if self.configOptions:
            self.config.update(self.configOptions)

        os.mkdir(self.config.ServerRoot)
        os.mkdir(os.path.join(self.config.ServerRoot, self.config.DocumentRoot))
        os.mkdir(os.path.join(self.config.ServerRoot, self.config.DataRoot))
        os.mkdir(os.path.join(self.config.ServerRoot, self.config.ConfigRoot))

        self.configFile = self.mktemp()

        self.writeConfig()
コード例 #8
0
 def setUp(self):
     """
     Create a memcache client, connect it to a string protocol, and make it
     use a deterministic clock.
     """
     TestCase.setUp(self)
     self.proto = MemCacheProtocol()
     self.clock = Clock()
     self.proto.callLater = self.clock.callLater
     self.transport = StringTransportWithDisconnection()
     self.transport.protocol = self.proto
     self.proto.makeConnection(self.transport)
コード例 #9
0
 def setUp(self):
     """
     Create a memcache client, connect it to a string protocol, and make it
     use a deterministic clock.
     """
     TestCase.setUp(self)
     self.proto = MemCacheProtocol()
     self.clock = Clock()
     self.proto.callLater = self.clock.callLater
     self.transport = StringTransportWithDisconnection()
     self.transport.protocol = self.proto
     self.proto.makeConnection(self.transport)
コード例 #10
0
    def setUp(self):
        """
        Create a DigestCredentialFactory for testing
        """
        TestCase.setUp(self)
        config.ProcessType = "Single"

        self.namespace1 = "DIGEST1"
        self.namespace2 = "DIGEST2"

        self.credentialFactories = (QopDigestCredentialFactory(
            'md5', 'auth', 'test realm', self.namespace1),
                                    QopDigestCredentialFactory(
                                        'md5', '', 'test realm',
                                        self.namespace2))
コード例 #11
0
 def setUp(self):
     """
     Create a L{MemCachePool}.
     """
     TestCase.setUp(self)
     self.reactor = StubReactor()
     self.pool = MemCachePool(
         TCP4ClientEndpoint(self.reactor, MC_ADDRESS.host, MC_ADDRESS.port),
         maxClients=5, reactor=self.reactor
     )
     realClientFactory = self.pool.clientFactory
     self.clientFactories = []
     def capturingClientFactory(*a, **k):
         cf = realClientFactory(*a, **k)
         self.clientFactories.append(cf)
         return cf
     self.pool.clientFactory = capturingClientFactory
コード例 #12
0
 def setUp(self):
     """
     Create a L{MemCachePool}.
     """
     TestCase.setUp(self)
     self.reactor = StubReactor()
     self.pool = MemCachePool(
         TCP4ClientEndpoint(self.reactor, MC_ADDRESS.host, MC_ADDRESS.port),
         maxClients=5, reactor=self.reactor
     )
     realClientFactory = self.pool.clientFactory
     self.clientFactories = []
     def capturingClientFactory(*a, **k):
         cf = realClientFactory(*a, **k)
         self.clientFactories.append(cf)
         return cf
     self.pool.clientFactory = capturingClientFactory
コード例 #13
0
    def setUp(self):
        """
        Create a DigestCredentialFactory for testing
        """
        TestCase.setUp(self)
        config.ProcessType = "Single"

        self.namespace1 = "DIGEST1"
        self.namespace2 = "DIGEST2"

        self.credentialFactories = (QopDigestCredentialFactory(
                                          'md5',
                                          'auth',
                                          'test realm',
                                          self.namespace1
                                      ),
                                      QopDigestCredentialFactory(
                                          'md5',
                                          '',
                                          'test realm',
                                          self.namespace2
                                      ))
コード例 #14
0
    def setUp(self):
        """
        Set up our options object, giving it a parent, and forcing the
        global config to be loaded from defaults.
        """
        TestCase.setUp(self)
        self.options = CalDAVTaskOptions()
        self.options.parent = Options()
        self.options.parent["uid"] = 0
        self.options.parent["gid"] = 0
        self.options.parent["nodaemon"] = False

        self.config = ConfigDict(DEFAULT_CONFIG)

        accountsFile = os.path.join(sourceRoot, "twistedcaldav/directory/test/accounts.xml")
        self.config["DirectoryService"] = {
            "params": {"xmlFile": accountsFile},
            "type": "twistedcaldav.directory.xmlfile.XMLDirectoryService"
        }

        self.config.DocumentRoot   = self.mktemp()
        self.config.DataRoot       = self.mktemp()
        self.config.ProcessType    = "Single"
        self.config.Memcached.ClientEnabled = False
        self.config.Memcached.ServerEnabled = False


        pemFile = os.path.join(sourceRoot, "twistedcaldav/test/data/server.pem")
        self.config.SSLPrivateKey = pemFile
        self.config.SSLCertificate = pemFile

        os.mkdir(self.config.DocumentRoot)
        os.mkdir(self.config.DataRoot)

        self.configFile = self.mktemp()

        self.writeConfig()
コード例 #15
0
 def setUp(self):
     TestCase.setUp(self)
     config.setProvider(PListConfigProvider(DEFAULT_CONFIG))
     self.testConfig = self.mktemp()
     with open(self.testConfig, "w") as f:
         f.write(testConfig)
コード例 #16
0
 def setUp(self):
     TestCase.setUp(self)
     self.resource = CalDAVResource()
     self.resource._dead_properties = InMemoryPropertyStore()
コード例 #17
0
ファイル: test_resource.py プロジェクト: nunb/calendarserver
 def setUp(self):
     TestCase.setUp(self)
     self.resource = CalDAVResource()
     self.resource._dead_properties = InMemoryPropertyStore()
コード例 #18
0
 def setUp(self):
     TestCase.setUp(self)
     self.handler = MailHandler(dataRoot=":memory:")
     self.dataDir = os.path.join(os.path.dirname(__file__), "data", "mail")
コード例 #19
0
 def setUp(self):
     TestCase.setUp(self)
     self.db = MailGatewayTokensDatabase(":memory:")
コード例 #20
0
 def setUp(self):
     TestCase.setUp(self)
     self.client = StubNotificationClient(None, None)
     self.factory = NotificationClientFactory(self.client)
     self.factory.protocol = StubNotificationClientProtocol
コード例 #21
0
 def setUp(self):
     TestCase.setUp(self)
     self.resource = TestCachingResource(StubResponse(200, {}, "foobar"))
     self.responseCache = StubResponseCacheResource()
コード例 #22
0
 def setUp(self):
     TestCase.setUp(self)
     self.clock = Clock()
     self.notifier = SimpleLineNotifier(None)
     self.coalescer = Coalescer([self.notifier], reactor=self.clock)
コード例 #23
0
 def setUp(self):
     TestCase.setUp(self)
     self.clock = Clock()
     self.notifier = StubNotifier()
     self.coalescer = Coalescer([self.notifier], reactor=self.clock)
コード例 #24
0
 def setUp(self):
     TestCase.setUp(self)
     self.client = NotifierFactory(None, None, reactor=Clock())
     self.client.factory = StubNotificationClientFactory()
コード例 #25
0
 def setUp(self):
     TestCase.setUp(self)
     config.setProvider(PListConfigProvider(DEFAULT_CONFIG))
     self.testConfig = self.mktemp()
     open(self.testConfig, "w").write(testConfig)
コード例 #26
0
 def setUp(self):
     TestCase.setUp(self)
     self.resource = TestCachingResource(StubResponse(200, {}, "foobar"))
     self.responseCache = StubResponseCacheResource()