Coverage for src/backend/InvenTree/plugin/samples/integration/sample_currency_exchange.py: 0%

15 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 17:47 +0000

1"""Sample plugin for providing dummy currency exchange data.""" 

2 

3import random 

4 

5from django.utils.translation import gettext_lazy as _ 

6 

7from plugin import InvenTreePlugin 

8from plugin.mixins import CurrencyExchangeMixin 

9 

10 

11class SampleCurrencyExchangePlugin(CurrencyExchangeMixin, InvenTreePlugin): 

12 """Dummy currency exchange plugin which provides fake exchange rates.""" 

13 

14 NAME = 'Sample Exchange' 

15 DESCRIPTION = _('Sample currency exchange plugin') 

16 SLUG = 'samplecurrencyexchange' 

17 VERSION = '0.1.0' 

18 AUTHOR = _('InvenTree Contributors') 

19 

20 def update_exchange_rates(self, base_currency: str, symbols: list[str]) -> dict: 

21 """Return dummy data for some currencies.""" 

22 rates = {base_currency: 1.00} 

23 

24 for symbol in symbols: 

25 rates[symbol] = random.randrange(5, 15) * 0.1 

26 

27 return rates