예제 #1
0
class TestInstrumentProvider:
    def setup(self):
        # Fixture Setup

        self.provider = InstrumentProvider()

    def test_load_all_async_when_not_implemented_raises_exception(self):
        # Fresh isolated loop testing pattern
        loop = asyncio.new_event_loop()
        asyncio.set_event_loop(loop)

        async def run_test():
            # Arrange
            # Act
            # Assert
            with pytest.raises(NotImplementedError):
                await self.provider.load_all_async()

        loop.run_until_complete(run_test())

    def test_load_all_when_not_implemented_raises_exception(self):
        # Arrange
        # Act
        # Assert
        with pytest.raises(NotImplementedError):
            self.provider.load_all()

    def test_load_when_not_implemented_raises_exception(self):
        # Arrange
        # Act
        # Assert
        with pytest.raises(NotImplementedError):
            self.provider.load(AUDUSD, {})

    def test_get_all_when_no_instruments_returns_empty_dict(self):
        # Arrange
        # Act
        result = self.provider.get_all()

        # Assert
        assert result == {}

    def test_find_when_no_instruments_returns_none(self):
        # Arrange
        # Act
        result = self.provider.find(AUDUSD)

        # Assert
        assert result is None
예제 #2
0
class TestInstrumentProvider:
    def setup(self):
        # Fixture Setup
        self.provider = InstrumentProvider()

    def test_get_all_when_no_instruments_returns_empty_dict(self):
        # Arrange, Act
        result = self.provider.get_all()

        # Assert
        assert result == {}

    def test_find_when_no_instruments_returns_none(self):
        # Arrange, Act
        result = self.provider.find(AUDUSD)

        # Assert
        assert result is None