Esempio n. 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')
Esempio n. 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)
Esempio n. 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)
Esempio n. 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')
Esempio n. 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)
Esempio n. 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)