def dummy_config(): return { "bank_service": None, "from_iban": 'from123', "to_iban": 'to123', "multiplier": BasicMultiplier() }
def handler(event, context): s3_manager = S3Manager(HEALTH_DATA_BUCKET_NAME, 'runs.csv', Run) endomondo_service = EndomondoService() if s3_manager.has_entries_online(): runs = endomondo_service.get_runs(5) max_id_in_s3 = s3_manager.get_max_int() else: runs = endomondo_service.get_runs(999) max_id_in_s3 = 0 runs_to_upload = [r for r in runs if r.get_id() > max_id_in_s3] if runs_to_upload: config = { "bank_service": BunqService(), "from_iban": PARAMETER_MANAGER.get('/bunq/from_iban'), "to_iban": PARAMETER_MANAGER.get('/bunq/to_iban'), "multiplier": BasicMultiplier() } payment_provider = PaymentProvider(config) payment_provider.pay_out(runs_to_upload) s3_manager.append(runs_to_upload)
def test_get_amount_with_weights(dummy_weights): m = BasicMultiplier() expected = -0.5 result = m.get_amount(dummy_weights) assert result == expected
def test_get_amount_with_run_times_10(dummy_run): m = BasicMultiplier(10) expected = 23.50 result = m.get_amount(dummy_run) assert result == expected
def test_get_amount_with_run(dummy_run): m = BasicMultiplier() expected = 2.35 result = m.get_amount(dummy_run) assert result == expected
def dummy_weight_multiplier(): return BasicMultiplier(10)
def dummy_multiplier(): return BasicMultiplier()
from typing import List, Optional, Tuple from services.banking import BunqService from services.multiplier import BasicMultiplier from models.workout import Run from models.body import Weights from models.payment_info import PaymentInfo from exceptions.money import PaymentDescriptionNotImplemented config = { "bank_service": BunqService(), "from_iban": 'from123', "to_iban": 'to123', "multiplier": BasicMultiplier() } class PaymentProvider(): def __init__(self, config: dict = config): self.bank_service = config.get("bank_service") self.from_iban = config.get("from_iban") self.to_iban = config.get("to_iban") self.multiplier = config.get("multiplier") def pay_out(self, data: List[object]): payment_jobs = self.create_payment_jobs(data, self.multiplier) for payment_job in payment_jobs: self.bank_service.make_payment(payment_job)