def test_qt_plugin(): louie.reset() # Create receivers. class Receiver(qt.QWidget): def __init__(self): qt.QObject.__init__(self) self.args = [] def receive(self, arg): self.args.append(arg) receiver1 = Receiver() receiver2 = Receiver() # Connect signals. louie.connect(receiver1.receive, 'sig') louie.connect(receiver2.receive, 'sig') # Destroy receiver2 so only a shell is left. receiver2.close(True) # Check reception without plugins. louie.send('sig', arg='foo') assert receiver1.args == ['foo'] assert receiver2.args == ['foo'] # Install plugin. plugin = louie.QtWidgetPlugin() louie.install_plugin(plugin) # Check reception with plugins. louie.send('sig', arg='bar') assert receiver1.args == ['foo', 'bar'] assert receiver2.args == ['foo']
def test_only_one_instance(): louie.reset() plugin1a = Plugin1() plugin1b = Plugin1() louie.install_plugin(plugin1a) # XXX: Move these tests into test cases so we can use unittest's # 'assertRaises' method. try: louie.install_plugin(plugin1b) except louie.error.PluginTypeError: pass else: raise Exception('PluginTypeError not raised')
def test_notification(self): louie.reset() User = db.User subscriber = self.Subscriber() louie.connect(subscriber, TransactionExecuted) # Execute a transaction before telling the database to # dispatch messages. tx = User.t.create(name='foo') db.execute(tx) assert tx not in subscriber.received # Turn on dispatching and execute another. db.dispatch = True tx = User.t.create(name='bar') db.execute(tx) assert tx in subscriber.received
def test_is_live(): louie.reset() # Create receivers. receiver1a = Receiver1() receiver1b = Receiver1() receiver2a = Receiver2() receiver2b = Receiver2() # Connect signals. louie.connect(receiver1a, 'sig') louie.connect(receiver1b, 'sig') louie.connect(receiver2a, 'sig') louie.connect(receiver2b, 'sig') # Check reception without plugins. louie.send('sig', arg='foo') assert receiver1a.args == ['foo'] assert receiver1b.args == ['foo'] assert receiver2a.args == ['foo'] assert receiver2b.args == ['foo'] # Install plugin 1. plugin1 = Plugin1() louie.install_plugin(plugin1) # Make some receivers not live. receiver1a.live = False receiver2b.live = False # Check reception. louie.send('sig', arg='bar') assert receiver1a.args == ['foo'] assert receiver1b.args == ['foo', 'bar'] assert receiver2a.args == ['foo', 'bar'] assert receiver2b.args == ['foo'] # Remove plugin 1, install plugin 2. plugin2 = Plugin2() louie.remove_plugin(plugin1) louie.install_plugin(plugin2) # Check reception. louie.send('sig', arg='baz') assert receiver1a.args == ['foo', 'baz'] assert receiver1b.args == ['foo', 'bar', 'baz'] assert receiver2a.args == ['foo', 'bar'] assert receiver2b.args == ['foo'] # Install plugin 1 alongside plugin 2. louie.install_plugin(plugin1) # Check reception. louie.send('sig', arg='fob') assert receiver1a.args == ['foo', 'baz'] assert receiver1b.args == ['foo', 'bar', 'baz', 'fob'] assert receiver2a.args == ['foo', 'bar'] assert receiver2b.args == ['foo']
def test_is_live(): louie.reset() # Create receivers. receiver1a = Receiver1() receiver1b = Receiver1() receiver2a = Receiver2() receiver2b = Receiver2() # Connect signals. louie.connect(receiver1a, "sig") louie.connect(receiver1b, "sig") louie.connect(receiver2a, "sig") louie.connect(receiver2b, "sig") # Check reception without plugins. louie.send("sig", arg="foo") assert receiver1a.args == ["foo"] assert receiver1b.args == ["foo"] assert receiver2a.args == ["foo"] assert receiver2b.args == ["foo"] # Install plugin 1. plugin1 = Plugin1() louie.install_plugin(plugin1) # Make some receivers not live. receiver1a.live = False receiver2b.live = False # Check reception. louie.send("sig", arg="bar") assert receiver1a.args == ["foo"] assert receiver1b.args == ["foo", "bar"] assert receiver2a.args == ["foo", "bar"] assert receiver2b.args == ["foo"] # Remove plugin 1, install plugin 2. plugin2 = Plugin2() louie.remove_plugin(plugin1) louie.install_plugin(plugin2) # Check reception. louie.send("sig", arg="baz") assert receiver1a.args == ["foo", "baz"] assert receiver1b.args == ["foo", "bar", "baz"] assert receiver2a.args == ["foo", "bar"] assert receiver2b.args == ["foo"] # Install plugin 1 alongside plugin 2. louie.install_plugin(plugin1) # Check reception. louie.send("sig", arg="fob") assert receiver1a.args == ["foo", "baz"] assert receiver1b.args == ["foo", "bar", "baz", "fob"] assert receiver2a.args == ["foo", "bar"] assert receiver2b.args == ["foo"]
def setUp(self): louie.reset()
def setUp(self): CreatesSchema.setUp(self) louie.reset() db.dispatch = True dist = self.dist = Distributor(db)