def test_get_given_none_raises_value_error(self, value, ex):
        # Arrange
        cache = ObjectCache(InstrumentId, InstrumentId.from_str)

        # Act
        # Assert
        with pytest.raises(ex):
            cache.get(value)
    def test_keys_when_cache_empty_returns_empty_list(self):
        # Arrange
        cache = ObjectCache(InstrumentId, InstrumentId.from_str)

        # Act
        result = cache.keys()

        # Assert
        assert [] == result
Exemple #3
0
    def test_cache_initialization(self):
        # Arrange
        cache = ObjectCache(Symbol, Symbol.from_str)

        # Act
        # Assert
        self.assertEqual(str, cache.type_key)
        self.assertEqual(Symbol, cache.type_value)
        self.assertEqual([], cache.keys())
    def test_cache_initialization(self):
        # Arrange
        cache = ObjectCache(InstrumentId, InstrumentId.from_str)

        # Act
        # Assert
        assert str == cache.type_key
        assert InstrumentId == cache.type_value
        assert [] == cache.keys()
Exemple #5
0
    def test_keys_when_cache_empty_returns_empty_list(self):
        # Arrange
        cache = ObjectCache(Symbol, Symbol.from_str)

        # Act
        result = cache.keys()

        # Assert
        self.assertEqual([], result)
    def test_cache_initialization(self):
        # Arrange
        cache = ObjectCache(InstrumentId, InstrumentId.from_str)

        # Act
        # Assert
        assert cache.type_key == str
        assert cache.type_value == InstrumentId
        assert cache.keys() == []
    def test_get_from_empty_cache(self):
        # Arrange
        cache = ObjectCache(InstrumentId, InstrumentId.from_str)
        instrument_id = "AUD/USD.SIM,FX,SPOT"

        # Act
        result = cache.get(instrument_id)

        # Assert
        assert instrument_id == str(result)
        assert ["AUD/USD.SIM,FX,SPOT"] == cache.keys()
Exemple #8
0
    def test_get_from_empty_cache(self):
        # Arrange
        cache = ObjectCache(Symbol, Symbol.from_str)
        symbol = "AUD/USD.SIM"

        # Act
        result = cache.get(symbol)

        # Assert
        self.assertEqual(symbol, str(result))
        self.assertEqual(["AUD/USD.SIM"], cache.keys())
    def test_can_get_from_empty_cache(self):
        # Arrange
        cache = ObjectCache(Symbol, Symbol.py_from_string)
        symbol = 'AUDUSD.FXCM'

        # Act
        result = cache.get(symbol)

        # Assert
        self.assertEqual(symbol, str(result))
        self.assertEqual(['AUDUSD.FXCM'], cache.keys())
Exemple #10
0
    def test_get_given_none_raises_value_error(self, value, ex):
        # Arrange
        cache = ObjectCache(Symbol, Symbol.from_str)

        # Act
        # Assert
        self.assertRaises(ex, cache.get, value)
    def test_clear_cache(self):
        # Arrange
        cache = ObjectCache(InstrumentId, InstrumentId.from_str)
        instrument_id = "AUD/USD.SIM,FX,SPOT"
        cache.get(instrument_id)

        # Act
        cache.clear()

        # Assert
        assert [] == cache.keys()
Exemple #12
0
    def test_clear_cache(self):
        # Arrange
        cache = ObjectCache(Symbol, Symbol.from_str)
        symbol = "AUD/USD.SIM"
        cache.get(symbol)

        # Act
        cache.clear()

        # Assert
        self.assertEqual([], cache.keys())
    def test_can_clear_cache(self):
        # Arrange
        cache = ObjectCache(Symbol, Symbol.py_from_string)
        symbol = 'AUDUSD.FXCM'
        cache.get(symbol)

        # Act
        cache.clear()

        # Assert
        self.assertEqual([], cache.keys())
    def test_get_from_cache(self):
        # Arrange
        cache = ObjectCache(InstrumentId, InstrumentId.from_str)
        instrument_id = "AUD/USD.SIM,FX,SPOT"
        cache.get(instrument_id)

        # Act
        cache.get(instrument_id)
        result1 = cache.get(instrument_id)
        result2 = cache.get(instrument_id)

        # Assert
        assert instrument_id == str(result1)
        assert id(result1) == id(result2)
        assert ["AUD/USD.SIM,FX,SPOT"] == cache.keys()
Exemple #15
0
    def test_get_from_cache(self):
        # Arrange
        cache = ObjectCache(Symbol, Symbol.from_str)
        symbol = "AUD/USD.SIM"
        cache.get(symbol)

        # Act
        cache.get(symbol)
        result1 = cache.get(symbol)
        result2 = cache.get(symbol)

        # Assert
        self.assertEqual(symbol, str(result1))
        self.assertEqual(id(result1), id(result2))
        self.assertEqual(["AUD/USD.SIM"], cache.keys())
    def test_can_get_from_cache(self):
        # Arrange
        cache = ObjectCache(Symbol, Symbol.py_from_string)
        symbol = 'AUDUSD.FXCM'
        cache.get(symbol)

        # Act
        cache.get(symbol)
        result1 = cache.get(symbol)
        result2 = cache.get(symbol)

        # Assert
        self.assertEqual(symbol, str(result1))
        self.assertEqual(id(result1), id(result2))
        self.assertEqual(['AUDUSD.FXCM'], cache.keys())