예제 #1
0
    def test_load_should_delegate_to_registered_providers(self):
        s_symbol = ""

        providerMock1 = mock(AbstractProvider)
        providerMock2 = mock(AbstractProvider)
        providerMock3 = mock(AbstractProvider)
        when(providerMock1).load(s_symbol).thenReturn(None)
        when(providerMock2).load(s_symbol).thenReturn(None)
        when(providerMock3).load(s_symbol).thenReturn(None)

        provider = Provider(providerMock1, providerMock2, providerMock3)
        provider.load(s_symbol)

        inorder.verify(providerMock1, times=1).load(s_symbol)
        inorder.verify(providerMock2, times=1).load(s_symbol)
        inorder.verify(providerMock3, times=1).load(s_symbol)
예제 #2
0
    def test_load_should_delegate_to_registered_providers(self):
        s_symbol = ""

        providerMock1 = mock(AbstractProvider)
        providerMock2 = mock(AbstractProvider)
        providerMock3 = mock(AbstractProvider)
        when(providerMock1).load(s_symbol).thenReturn(None)
        when(providerMock2).load(s_symbol).thenReturn(None)
        when(providerMock3).load(s_symbol).thenReturn(None)

        provider = Provider(providerMock1, providerMock2, providerMock3)
        provider.load(s_symbol)

        inorder.verify(providerMock1, times=1).load(s_symbol)
        inorder.verify(providerMock2, times=1).load(s_symbol)
        inorder.verify(providerMock3, times=1).load(s_symbol)
예제 #3
0
    def test_load_should_delegate_sequentially_till_one_returns_data(self):
        s_symbol = ""
        l_data = ["Sample data"]

        providerMock1 = mock(AbstractProvider)
        providerMock2 = mock(AbstractProvider)
        providerMock3 = mock(AbstractProvider)
        when(providerMock1).load(s_symbol).thenReturn(None)
        when(providerMock2).load(s_symbol).thenReturn(l_data)
        when(providerMock3).load(s_symbol).thenReturn(None)

        provider = Provider(providerMock1, providerMock2, providerMock3)
        result = provider.load(s_symbol)

        assert result == l_data
        inorder.verify(providerMock1, times=1).load(s_symbol)
        inorder.verify(providerMock2, times=1).load(s_symbol)
        inorder.verify(providerMock3, times=0).load(s_symbol)
예제 #4
0
    def test_load_should_delegate_sequentially_till_one_returns_data(self):
        s_symbol = ""
        l_data = ["Sample data"]

        providerMock1 = mock(AbstractProvider)
        providerMock2 = mock(AbstractProvider)
        providerMock3 = mock(AbstractProvider)
        when(providerMock1).load(s_symbol).thenReturn(None)
        when(providerMock2).load(s_symbol).thenReturn(l_data)
        when(providerMock3).load(s_symbol).thenReturn(None)

        provider = Provider(providerMock1, providerMock2, providerMock3)
        result = provider.load(s_symbol)

        assert result == l_data
        inorder.verify(providerMock1, times=1).load(s_symbol)
        inorder.verify(providerMock2, times=1).load(s_symbol)
        inorder.verify(providerMock3, times=0).load(s_symbol)
예제 #5
0
    def test_load_should_update_providers_that_had_no_data(self):
        s_symbol = ""
        l_data = ["Sample data"]

        providerMock1 = mock(AbstractProvider)
        providerMock2 = mock(AbstractProvider)
        providerMock3 = mock(AbstractProvider)
        when(providerMock1).load(s_symbol).thenReturn(None)
        when(providerMock2).load(s_symbol).thenReturn(None)
        when(providerMock3).load(s_symbol).thenReturn(l_data)

        provider = Provider(providerMock1, providerMock2, providerMock3)
        result = provider.load(s_symbol)

        assert result == l_data
        inorder.verify(providerMock1, times=1).load(s_symbol)
        inorder.verify(providerMock2, times=1).load(s_symbol)
        inorder.verify(providerMock3, times=1).load(s_symbol)

        inorder.verify(providerMock3, times=0).update(anyv(), anyv())
        inorder.verify(providerMock2, times=1).update(s_symbol, l_data)
        inorder.verify(providerMock1, times=1).update(s_symbol, l_data)
예제 #6
0
    def test_load_should_update_providers_that_had_no_data(self):
        s_symbol = ""
        l_data = ["Sample data"]

        providerMock1 = mock(AbstractProvider)
        providerMock2 = mock(AbstractProvider)
        providerMock3 = mock(AbstractProvider)
        when(providerMock1).load(s_symbol).thenReturn(None)
        when(providerMock2).load(s_symbol).thenReturn(None)
        when(providerMock3).load(s_symbol).thenReturn(l_data)

        provider = Provider(providerMock1, providerMock2, providerMock3)
        result = provider.load(s_symbol)

        assert result == l_data
        inorder.verify(providerMock1, times=1).load(s_symbol)
        inorder.verify(providerMock2, times=1).load(s_symbol)
        inorder.verify(providerMock3, times=1).load(s_symbol)

        inorder.verify(providerMock3, times=0).update(anyv(), anyv())
        inorder.verify(providerMock2, times=1).update(s_symbol, l_data)
        inorder.verify(providerMock1, times=1).update(s_symbol, l_data)
예제 #7
0
 def test_load_should_return_None_if_no_providers_where_registered(self):
     provider = Provider()
     assert provider.load("") is None
예제 #8
0
 def test_should_subclass_abstractProvider(self):
     provider = Provider()
     assert isinstance(provider, AbstractProvider)
예제 #9
0
 def test_load_should_return_None_if_no_providers_where_registered(self):
     provider = Provider()
     assert provider.load("") is None