def test_balance_model_initial_balance(): """ARRANGE""" expected_balance = 0 """ACT""" model = BalanceModel() """ASSERT""" assert model.balance == expected_balance
def test_free_money_success( dapp_registry: Registry, key_manager: KeyManager, ): """ ARRANGE """ receiver_address = key_manager.generate() receiver_initial_balance = 100 free_money_amount = 100 what_is_this_id = str(uuid4()) transform = FreeMoney( receiver=receiver_address, amount=free_money_amount, ) # Initialize the environment. state = create_state(dapp_registry) balance_state = state[BalanceModel.fqdn] balance_state[receiver_address] = BalanceModel( balance=receiver_initial_balance) """ ACT """ execute_transform(transform, state) the_receiver: BalanceModel = balance_state[receiver_address] """ ASSERT """ assert the_receiver.balance == receiver_initial_balance + free_money_amount
def test_balance_transfer_zero_money_error( dapp_registry: Registry, key_manager: KeyManager, ): """ ARRANGE """ #Define fake values for the transform sender_address = key_manager.generate() sender_initial_balance = 100 receiver_initial_balance = 100 receiver_address = key_manager.generate() send_amount = 0 what_is_this_id = str(uuid4()) ##Build the Transform transform = BalanceTransfer( sender=sender_address, receiver=receiver_address, amount=send_amount, ) #Create a fake state state = create_state(dapp_registry) balance_state = state[BalanceModel.fqdn] #Set Initial Balance for Sender balance_state[sender_address] = BalanceModel( balance=sender_initial_balance) #Set Inital Balance for receiver balance_state[receiver_address] = BalanceModel( balance=receiver_initial_balance) """ ACT """ #Run the Transform with pytest.raises(InvalidAmountError): execute_transform(transform, state) #Define the balance models of the sender and receiver the_receiver: BalanceModel = balance_state[receiver_address] the_sender: BalanceModel = balance_state[sender_address] """ ASSERT """ assert the_receiver.balance == receiver_initial_balance assert the_sender.balance == sender_initial_balance
def test_balance_model_set_balance(): """ARRANGE""" balance = 100 expected_balance = balance """ACT""" model = BalanceModel(balance) """ASSERT""" assert model.balance == expected_balance