示例#1
0
def test_count():
    r = TopicsRegistry()
    t1 = Topic('test1')
    r.register(t1)
    assert r.count() == 1
    t2 = Topic('test2')
    t3 = Topic('test3')
    r.register(t2)
    r.register(t3)
    assert r.count() == 3
示例#2
0
def test_register():
    r = TopicsRegistry()
    t = Topic('test')
    r.register(t)
    assert r.count() == 1

    # registering the same topic multiple times won't change it
    r.register(t)
    assert r.count() == 1

    # ... but a new one, will
    t2 = Topic('test2')
    r.register(t2)
    assert r.count() == 2