Exemplo n.º 1
0
Arquivo: test.py Projeto: uniite/pyirc
 def test_remove(self):
     # Create an observable dict
     observable_dict = ObservableDict({"good": "bye"})
     # Subscribe to remove events
     subscription = observable_dict.subscribe("remove", self.callback)
     # Remove an item from it
     del observable_dict["good"]
     # Ensure this triggered the callback
     self.assertEqual(("good", "bye"), self.callback_result)
Exemplo n.º 2
0
Arquivo: test.py Projeto: uniite/pyirc
 def test_change(self):
     # Create an observable dict
     observable_dict = ObservableDict({"good": "bye"})
     # Subscribe to change events
     subscription = observable_dict.subscribe("change", self.callback)
     # Change an item in it
     observable_dict["good"] = "morning"
     # Ensure this triggered the callback
     self.assertEqual(("good", "morning"), self.callback_result)
Exemplo n.º 3
0
Arquivo: test.py Projeto: uniite/pyirc
 def test_add(self):
     # Create an observable dict
     observable_dict = ObservableDict()
     # Subscribe to add events
     subscription = observable_dict.subscribe("add", self.callback)
     # Add an item to it
     observable_dict["foo"] = "bar"
     # Ensure this triggered the callback
     self.assertEqual(("foo", "bar"), self.callback_result)
Exemplo n.º 4
0
Arquivo: test.py Projeto: uniite/pyirc
 def test_propagation(self):
     class Alerter(SimpleObservable):
         def alert(self):
             self._notify(None, "alert", "Alert!")
     # Create an observable dict that contains other observables
     observable_dict = ObservableDict({
         "this": Alerter(),
         "that": Alerter()
     })
     # Subscribe to all events
     subscription = observable_dict.subscribe("__all__", self.callback)
     # Trigger an alert on something in the dict
     observable_dict["that"].alert()
     # Ensure this triggered the callback
     self.assertEqual((("that", None), "alert", "Alert!"), self.callback_result)