mirror of
https://git.photon.obnh.io/AXSY/whois.git
synced 2026-03-13 02:01:32 +00:00
Initial commit: mwhois with SCION AS support and decimal AS conversion
Based on mwhois by Antonios A. Chariton Modifications for SCION AS support by Olaf Baumert, Axpo Systems AG
This commit is contained in:
48
netaddr/tests/2.x/core/pubsub.txt
Normal file
48
netaddr/tests/2.x/core/pubsub.txt
Normal file
@@ -0,0 +1,48 @@
|
||||
=Publish / Subscribe DP Tests=
|
||||
|
||||
Copyright (c) 2008-2015, David P. D. Moss. All rights reserved.
|
||||
|
||||
Basic Publisher and Subscriber object tests.
|
||||
|
||||
{{{
|
||||
|
||||
>>> from netaddr.core import Publisher, Subscriber, PrettyPrinter
|
||||
>>> import pprint
|
||||
|
||||
>>> class Subject(Publisher):
|
||||
... pass
|
||||
|
||||
|
||||
>>> class Observer(Subscriber):
|
||||
... def __init__(self, id):
|
||||
... self.id = id
|
||||
...
|
||||
... def update(self, data):
|
||||
... return repr(self), pprint.pformat(data)
|
||||
...
|
||||
... def __repr__(self):
|
||||
... return '%s(%r)' % (self.__class__.__name__, self.id)
|
||||
...
|
||||
|
||||
>>> s = Subject()
|
||||
|
||||
>>> s.attach(Observer('foo'))
|
||||
>>> s.attach(Observer('bar'))
|
||||
|
||||
#FIXME: >>> pp = PrettyPrinter()
|
||||
#FIXME: >>> s.attach(pp)
|
||||
|
||||
>>> data = [{'foo': 42}, {'list': [1,'2', list(range(10))]}, {'strings': ['foo', 'bar', 'baz', 'quux']}]
|
||||
>>> s.notify(data)
|
||||
|
||||
#FIXME: >>> s.detach(pp)
|
||||
>>> s.notify(['foo', 'bar', 'baz'])
|
||||
|
||||
>>> s.attach('foo')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
TypeError: 'foo' does not support required interface!
|
||||
|
||||
>>> s.detach('foo')
|
||||
|
||||
}}}
|
||||
Reference in New Issue
Block a user