Пример #1
0
 def test_create_payment_description_weightgain(self, dummy_config,
                                                dummy_multiplier):
     weights = Weights(old=80, new=80.5)
     expected = "Because you gained 0.5 kg!"
     payment_provider = PaymentProvider(dummy_config)
     result = payment_provider.create_payment_description(weights)
     assert result == expected
Пример #2
0
    def test_create_payment_info(self, dummy_config, dummy_run,
                                 dummy_multiplier):
        expected = PaymentInfo(amount_string='2.35',
                               description='Because you ran 2.35 km!',
                               from_iban='from123',
                               to_iban='to123')
        payment_provider = PaymentProvider(dummy_config)
        result = payment_provider.create_payment_info(dummy_run,
                                                      dummy_multiplier)

        assert str(expected) == str(result)
Пример #3
0
    def test_create_amount_from_and_to_ibans_weightloss(
            self, dummy_weight_multiplier, dummy_config) -> str:
        weights = Weights(old=80.5, new=80)
        expected_amount_string = "5.0"
        expected_from_iban = "from123"
        expected_to_iban = "to123"

        payment_provider = PaymentProvider(dummy_config)
        amount_string, from_iban, to_iban = payment_provider.create_amount_from_and_to_ibans(
            weights, dummy_weight_multiplier)

        assert amount_string == expected_amount_string
        assert from_iban == expected_from_iban
        assert to_iban == expected_to_iban
Пример #4
0
    def test_create_amount_from_and_to_ibans_run(self, dummy_run,
                                                 dummy_multiplier,
                                                 dummy_config) -> str:
        expected_amount_string = "2.35"
        expected_from_iban = "from123"
        expected_to_iban = "to123"

        payment_provider = PaymentProvider(dummy_config)
        amount_string, from_iban, to_iban = payment_provider.create_amount_from_and_to_ibans(
            dummy_run, dummy_multiplier)

        assert amount_string == expected_amount_string
        assert from_iban == expected_from_iban
        assert to_iban == expected_to_iban
Пример #5
0
    def test_create_payment_jobs(self, dummy_config, dummy_run,
                                 dummy_multiplier):
        weights = Weights(old=80.5, new=80)

        l = [weights, dummy_run]

        payment_provider = PaymentProvider(dummy_config)
        result = payment_provider.create_payment_jobs(l, dummy_multiplier)

        assert str(result[0]) == str(
            PaymentInfo(amount_string='0.5',
                        description='Because you lost 0.5 kg!',
                        to_iban='to123',
                        from_iban='from123'))

        assert str(result[1]) == str(
            PaymentInfo(amount_string='2.35',
                        description='Because you ran 2.35 km!',
                        to_iban='to123',
                        from_iban='from123'))
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)
Пример #7
0
 def test_create_payment_description_run(self, dummy_run, dummy_config,
                                         dummy_multiplier):
     expected = "Because you ran 2.35 km!"
     payment_provider = PaymentProvider(dummy_config)
     result = payment_provider.create_payment_description(dummy_run)
     assert result == expected
Пример #8
0
 def test_create_payment_description_unknown_model(self, dummy_config):
     payment_provider = PaymentProvider(dummy_config)
     with pytest.raises(PaymentDescriptionNotImplemented):
         payment_provider.create_payment_description("abc")