Exemple #1
0
    def test_find_mocker_not_found(self) -> None:
        '''tormnet.fixtures._find_mocker('fakesymbol', ContextStub) == lambda: False'''
        class ContextStub(contexts.TestContext):
            pass

        c = ContextStub()

        method = fixtures._find_mocker('fakesymbol', c)
        self.assertFalse(method())
        self.assertEqual(method.__name__, 'noop')
Exemple #2
0
    def test_find_mocker_found_many_levels(self) -> None:
        '''tormnet.fixtures._find_mocker('symbol.sub.a.b', ContextStub) == mock_symbol_sub_a_b'''
        class ContextStub(contexts.TestContext):
            def mock_symbol_sub_a_b(self):
                pass

        c = ContextStub()

        method = fixtures._find_mocker('symbol.sub.a.b', c)
        self.assertEqual(method, c.mock_symbol_sub_a_b)
Exemple #3
0
    def test_find_mocker_found_zero_levels(self) -> None:
        '''tormnet.fixtures._find_mocker('symbol', ContextStub) == mock_symbol'''
        class ContextStub(contexts.TestContext):
            def mock_symbol(self):
                pass

        c = ContextStub()

        method = fixtures._find_mocker('symbol', c)
        self.assertEqual(method, c.mock_symbol)
Exemple #4
0
    def test_find_mocker_not_found(self) -> None:
        '''tormnet.fixtures._find_mocker('fakesymbol', ContextStub) == lambda: False'''

        class ContextStub(contexts.TestContext):
            pass

        c = ContextStub()

        method = fixtures._find_mocker('fakesymbol', c)
        self.assertFalse(method())
        self.assertEqual(method.__name__, 'noop')
Exemple #5
0
    def test_find_mocker_found_many_levels(self) -> None:
        '''tormnet.fixtures._find_mocker('symbol.sub.a.b', ContextStub) == mock_symbol_sub_a_b'''

        class ContextStub(contexts.TestContext):
            def mock_symbol_sub_a_b(self):
                pass

        c = ContextStub()

        method = fixtures._find_mocker('symbol.sub.a.b', c)
        self.assertEqual(method, c.mock_symbol_sub_a_b)
Exemple #6
0
    def test_find_mocker_found_zero_levels(self) -> None:
        '''tormnet.fixtures._find_mocker('symbol', ContextStub) == mock_symbol'''

        class ContextStub(contexts.TestContext):
            def mock_symbol(self):
                pass

        c = ContextStub()

        method = fixtures._find_mocker('symbol', c)
        self.assertEqual(method, c.mock_symbol)