Esempio n. 1
0
    def test_observer_multiple_observers(self):
        observer1 = Mock()
        observer2 = Mock()

        kb.add_observer(None, None, observer1)
        kb.add_observer(None, None, observer2)
        kb.raw_write('a', 'b', 1)

        observer1.assert_called_once_with('a', 'b', 1)
        observer2.assert_called_once_with('a', 'b', 1)
Esempio n. 2
0
    def test_observer_multiple_observers(self):
        observer1 = Mock()
        observer2 = Mock()
        
        kb.add_observer(None, None, observer1)
        kb.add_observer(None, None, observer2)
        kb.raw_write('a', 'b', 1)

        observer1.assert_called_once_with('a', 'b', 1)
        observer2.assert_called_once_with('a', 'b', 1)
Esempio n. 3
0
    def test_observer_all(self):
        observer = Mock()

        kb.add_observer(None, None, observer)
        kb.raw_write('a', 'b', 1)

        observer.assert_called_once_with('a', 'b', 1)
        observer.reset_mock()

        i = MockInfo()
        kb.append('a', 'c', i)
        observer.assert_called_with('a', 'c', i)
Esempio n. 4
0
 def test_observer_all(self):
     observer = Mock()
     
     kb.add_observer(None, None, observer)
     kb.raw_write('a', 'b', 1)
     
     observer.assert_called_once_with('a', 'b', 1)
     observer.reset_mock()
     
     i = MockInfo()
     kb.append('a', 'c', i)
     observer.assert_called_with('a', 'c', i)
Esempio n. 5
0
    def test_observer_location_b(self):
        observer = Mock()

        kb.add_observer('a', 'b', observer)
        kb.raw_write('a', 'b', 1)

        observer.assert_called_once_with('a', 'b', 1)
        observer.reset_mock()

        # Shouldn't call the observer
        kb.raw_write('a', 'xyz', 1)
        self.assertFalse(observer.called)

        i = MockInfo()
        kb.append('a', 'b', i)
        observer.assert_called_with('a', 'b', i)
Esempio n. 6
0
 def test_observer_location_b(self):
     observer = Mock()
     
     kb.add_observer('a', 'b', observer)
     kb.raw_write('a', 'b', 1)
     
     observer.assert_called_once_with('a', 'b', 1)
     observer.reset_mock()
     
     # Shouldn't call the observer
     kb.raw_write('a', 'xyz', 1)
     self.assertFalse(observer.called)
     
     i = MockInfo()
     kb.append('a', 'b', i)
     observer.assert_called_with('a', 'b', i)