Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fakeendpoint.py 1.6KB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # -*- test-case-name: twisted.internet.test.test_endpoints -*-
  2. # Copyright (c) Twisted Matrix Laboratories.
  3. # See LICENSE for details.
  4. """
  5. Fake client and server endpoint string parser plugins for testing purposes.
  6. """
  7. from zope.interface.declarations import implementer
  8. from twisted.internet.interfaces import (
  9. IStreamClientEndpoint,
  10. IStreamClientEndpointStringParserWithReactor,
  11. IStreamServerEndpoint,
  12. IStreamServerEndpointStringParser,
  13. )
  14. from twisted.plugin import IPlugin
  15. @implementer(IPlugin)
  16. class PluginBase:
  17. def __init__(self, pfx):
  18. self.prefix = pfx
  19. @implementer(IStreamClientEndpointStringParserWithReactor)
  20. class FakeClientParserWithReactor(PluginBase):
  21. def parseStreamClient(self, *a, **kw):
  22. return StreamClient(self, a, kw)
  23. @implementer(IStreamServerEndpointStringParser)
  24. class FakeParser(PluginBase):
  25. def parseStreamServer(self, *a, **kw):
  26. return StreamServer(self, a, kw)
  27. class EndpointBase:
  28. def __init__(self, parser, args, kwargs):
  29. self.parser = parser
  30. self.args = args
  31. self.kwargs = kwargs
  32. @implementer(IStreamClientEndpoint)
  33. class StreamClient(EndpointBase):
  34. def connect(self, protocolFactory=None):
  35. # IStreamClientEndpoint.connect
  36. pass
  37. @implementer(IStreamServerEndpoint)
  38. class StreamServer(EndpointBase):
  39. def listen(self, protocolFactory=None):
  40. # IStreamClientEndpoint.listen
  41. pass
  42. # Instantiate plugin interface providers to register them.
  43. fake = FakeParser("fake")
  44. fakeClientWithReactor = FakeClientParserWithReactor("crfake")
  45. fakeClientWithReactorAndPreference = FakeClientParserWithReactor("cpfake")