Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow any args to mocked request #288

Open
wants to merge 1 commit into
base: 2022/python
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions bitcoin/testing.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
class FakeResponse():

class FakeResponse:
def __init__(self):
self.status_code = 200
self.text = '{"bpi":{"USD":{"code":"USD","symbol": "$","rate":"37,817.3283","description":"United States Dollar","rate_float": 37817.3283}}}'

def json(*args):
return {
"bpi": {
"USD": {
"code": "USD",
"symbol": "$",
"rate": "37,817.3283",
"description": "United States Dollar",
"rate_float": 37817.3283
}
"bpi": {
"USD": {
"code": "USD",
"symbol": "$",
"rate": "37,817.3283",
"description": "United States Dollar",
"rate_float": 37817.3283,
}
}

}

# Mock raise_for_status
def raise_for_status(self):
pass


import requests
requests.get = lambda x, *args, **kwargs: FakeResponse()

requests.get = lambda *args, **kwargs: FakeResponse()

# Run bitcoin via import
import bitcoin
Expand All @@ -33,4 +34,4 @@ def raise_for_status(self):
except AttributeError:

# Bitcoin has no main function
pass
pass