1212from aiopg .sa .result import RowProxy
1313from faker import Faker
1414from pytest_simcore .helpers .rawdata_fakers import random_payment_method , utcnow
15- from simcore_postgres_database import errors
1615from simcore_postgres_database .models .payments_methods import (
1716 InitPromptAckFlowState ,
1817 payments_methods ,
@@ -47,19 +46,17 @@ async def _upsert_autorecharge(
4746 wallet_id ,
4847 enabled ,
4948 primary_payment_method_id ,
50- min_balance_in_usd ,
5149 top_up_amount_in_usd ,
52- top_up_countdown ,
50+ monthly_limit_in_usd ,
5351) -> RowProxy :
5452 # using this primary payment-method, create an autorecharge
5553 # NOTE: requires the entire
5654 stmt = AutoRechargeStmts .upsert_wallet_autorecharge (
5755 wallet_id = wallet_id ,
5856 enabled = enabled ,
5957 primary_payment_method_id = primary_payment_method_id ,
60- min_balance_in_usd = min_balance_in_usd ,
6158 top_up_amount_in_usd = top_up_amount_in_usd ,
62- top_up_countdown = top_up_countdown ,
59+ monthly_limit_in_usd = monthly_limit_in_usd ,
6360 )
6461 row = await (await connection .execute (stmt )).first ()
6562 assert row
@@ -71,12 +68,6 @@ async def _update_autorecharge(connection, wallet_id, **settings) -> int | None:
7168 return await connection .scalar (stmt )
7269
7370
74- async def _decrease_countdown (connection , wallet_id ) -> int | None :
75- stmt = AutoRechargeStmts .decrease_wallet_autorecharge_countdown (wallet_id )
76- # updates payments countdown
77- return await connection .scalar (stmt )
78-
79-
8071PaymentMethodRow : TypeAlias = RowProxy
8172
8273
@@ -123,41 +114,24 @@ async def test_payments_automation_workflow(
123114 wallet_id ,
124115 enabled = True ,
125116 primary_payment_method_id = payment_method_id ,
126- min_balance_in_usd = 10 ,
127117 top_up_amount_in_usd = 100 ,
128- top_up_countdown = 5 ,
118+ monthly_limit_in_usd = None ,
129119 )
130120
131121 auto_recharge = await _get_auto_recharge (connection , wallet_id )
132122 assert auto_recharge is not None
133123 assert auto_recharge .primary_payment_method_id == payment_method_id
134124 assert auto_recharge .enabled is True
135125
136- # countdown
137- assert await _decrease_countdown (connection , wallet_id ) == 4
138- assert await _decrease_countdown (connection , wallet_id ) == 3
139- assert await _decrease_countdown (connection , wallet_id ) == 2
140- assert await _decrease_countdown (connection , wallet_id ) == 1
141- assert await _decrease_countdown (connection , wallet_id ) == 0
142-
143- with pytest .raises (errors .CheckViolation ) as err_info :
144- await _decrease_countdown (connection , wallet_id )
145-
146- exc = err_info .value
147- assert exc .pgerror
148- assert "check_top_up_countdown_nonnegative" in exc .pgerror
149-
150126 # upsert: deactivate countdown
151127 auto_recharge = await _upsert_autorecharge (
152128 connection ,
153129 wallet_id ,
154130 enabled = True ,
155131 primary_payment_method_id = payment_method_id ,
156- min_balance_in_usd = 10 ,
157132 top_up_amount_in_usd = 100 ,
158- top_up_countdown = None , # <----
133+ monthly_limit_in_usd = 10000 , # <----
159134 )
160- assert auto_recharge .top_up_countdown is None
135+ assert auto_recharge .monthly_limit_in_usd == 10000
161136
162- await _update_autorecharge (connection , wallet_id , top_up_countdown = None )
163- assert await _decrease_countdown (connection , wallet_id ) is None
137+ await _update_autorecharge (connection , wallet_id , monthly_limit_in_usd = None )
0 commit comments