def test_process_json_result(hass, symbols, result, expected_error_encountered, expected_conversion_count): """No update is performed if update_interval is None.""" mock_coordinator = YahooSymbolUpdateCoordinator(symbols, hass, None) def prefix_conversion_symbol(symbol: str, symbol_data: any): return f"USD{symbol}" mock_fix_conversion_symbol = Mock(side_effect=prefix_conversion_symbol) mock_coordinator.fix_conversion_symbol = mock_fix_conversion_symbol (error_encountered, data) = mock_coordinator.process_json_result(result) assert len( mock_fix_conversion_symbol.mock_calls) == expected_conversion_count assert error_encountered is expected_error_encountered assert data is not None
def test_fix_conversion_symbol(hass, symbol, symbol_data, expected_symbol): """Test conversion symbol correction.""" mock_coordinator = YahooSymbolUpdateCoordinator([TEST_SYMBOL], hass, None) assert (mock_coordinator.fix_conversion_symbol( symbol, symbol_data) == expected_symbol)