Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from unittest import TestCase | ||
from pyff.mdrepo import Observable | ||
|
||
|
||
class TestObservable(TestCase): | ||
|
||
class Foo(Observable): | ||
def __init__(self, done=False): | ||
super(TestObservable.Foo, self).__init__() | ||
self.done = done | ||
|
||
|
||
def test_create_observable(self): | ||
o = TestObservable.Foo() | ||
assert(o is not None) | ||
assert(isinstance(o, Observable)) | ||
|
||
def test_observe(self): | ||
|
||
def _cb(event): | ||
assert('a' in event) | ||
assert('b' not in event) | ||
assert('myself' in event) | ||
assert(event['a'] == 1) | ||
assert(not event['myself'].done) | ||
event['myself'].done = True | ||
|
||
o = TestObservable.Foo() | ||
o.subscribe(_cb) | ||
o.fire(a=1,myself=o) | ||
assert o.done |