def test_value_should_return_the_weighted_stock_amount_for_all_stocks_in_the_wallet(self):
        # Given
        rate_provider = Mock()
        rate_provider.rate.side_effect = [89, 7000]

        # When
        wallet_value = Wallet([Stock(10, PETROLEUM), Stock(2, BITCOIN)]).value(EUR, rate_provider)

        # Then
        self.assertEqual(wallet_value, Amount(14890, EUR))
        rate_provider.rate.assert_has_calls(
            [
                call(PETROLEUM, EUR),
                call(BITCOIN, EUR)
            ])
示例#2
0
 async def get_wallet(self, wallet_id: int) -> Wallet:
     obj = await self.db.fetchrow(
         "SELECT id, balance, created_at FROM wallet where id = $1",
         wallet_id)
     return obj if obj is None else Wallet(**dict(obj))