Skip to content

Instantly share code, notes, and snippets.

@fusion44
Last active January 28, 2018 12:06
Show Gist options
  • Save fusion44/f96c894f565da5161d2e9e9e7ad83a75 to your computer and use it in GitHub Desktop.
Save fusion44/f96c894f565da5161d2e9e9e7ad83a75 to your computer and use it in GitHub Desktop.
# Django 2.0.1
# This probably has something todo tith this: https://docs.python.org/dev/library/unittest.mock.html#where-to-patch
# I can't figure out the right way to patch the usage of this function.
# this prints True:
print(hasattr(backend.transactions.fetchers.generic_exchange,
"update_exchange_tx_generic"))
# but my lambda is never called and throws no error
monkeypatch.setattr(backend.transactions.fetchers.generic_exchange,
"update_exchange_tx_generic",
lambda account: print("lambda"))
# this is the user script of the function
import graphene
from backend.transactions.fetchers.generic_exchange import update_exchange_tx_generic
class AccountRefreshTransactionsMutation(graphene.relay.ClientIDMutation):
@classmethod
def mutate(cls, root, info, input) -> "AccountRefreshTransactionsMutation":
# ...
update_exchange_tx_generic(account)
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment