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.

receiver.py 1.1KB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright (c) Twisted Matrix Laboratories.
  2. # See LICENSE for details.
  3. """
  4. Receivers for use in tests.
  5. """
  6. from twisted.positioning import base, ipositioning
  7. class MockPositioningReceiver(base.BasePositioningReceiver):
  8. """
  9. A mock positioning receiver.
  10. Mocks all the L{IPositioningReceiver} methods with stubs that don't do
  11. anything but register that they were called.
  12. @ivar called: A mapping of names of callbacks that have been called to
  13. C{True}.
  14. @type called: C{dict}
  15. """
  16. def __init__(self):
  17. self.clear()
  18. for methodName in ipositioning.IPositioningReceiver:
  19. self._addCallback(methodName)
  20. def clear(self):
  21. """
  22. Forget all the methods that have been called on this receiver, by
  23. emptying C{self.called}.
  24. """
  25. self.called = {}
  26. def _addCallback(self, name):
  27. """
  28. Adds a callback of the given name, setting C{self.called[name]} to
  29. C{True} when called.
  30. """
  31. def callback(*a, **kw):
  32. self.called[name] = True
  33. setattr(self, name, callback)