def test_find_by_address_returns_a_new_wallet_if_does_not_exist(redis): address = "AThM5PNSKdU9pu1ydqQnzRWVeNCGr8HKof" manager = WalletManager() wallet = manager.find_by_address(address) assert wallet.address == address assert wallet.public_key is None keys = redis.keys("*") assert keys == []
def test_find_by_address_returns_existing_wallet(redis): address = "AThM5PNSKdU9pu1ydqQnzRWVeNCGr8HKof" key = "wallets:address:{}".format(address).encode() manager = WalletManager() redis.set(key, Wallet({"address": address, "username": "******"}).to_json()) wallet = manager.find_by_address(address) assert wallet.address == address assert wallet.username == "spongebob" keys = redis.keys("*") assert keys == [key]
def test_find_by_address_raises_value_error_if_address_is_not_str(redis): address = b"AThM5PNSKdU9pu1ydqQnzRWVeNCGr8HKof" manager = WalletManager() with pytest.raises(ValueError): manager.find_by_address(address)