1 # -*- test-case-name: twisted.internet.test.test_endpoints -*-
2 # Copyright (c) Twisted Matrix Laboratories.
3 # See LICENSE for details.
6 Fake client and server endpoint string parser plugins for testing purposes.
9 from zope.interface.declarations import implements
10 from twisted.plugin import IPlugin
11 from twisted.internet.interfaces import (IStreamClientEndpoint,
12 IStreamServerEndpoint,
13 IStreamClientEndpointStringParser,
14 IStreamServerEndpointStringParser)
16 class PluginBase(object):
19 def __init__(self, pfx):
24 class FakeClientParser(PluginBase):
26 implements(IStreamClientEndpointStringParser)
28 def parseStreamClient(self, *a, **kw):
29 return StreamClient(self, a, kw)
33 class FakeParser(PluginBase):
35 implements(IStreamServerEndpointStringParser)
37 def parseStreamServer(self, *a, **kw):
38 return StreamServer(self, a, kw)
42 class EndpointBase(object):
44 def __init__(self, parser, args, kwargs):
51 class StreamClient(EndpointBase):
53 implements(IStreamClientEndpoint)
57 class StreamServer(EndpointBase):
59 implements(IStreamServerEndpoint)
63 # Instantiate plugin interface providers to register them.
64 fake = FakeParser('fake')
65 fakeClient = FakeClientParser('cfake')