-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructuring so tests are with application code pytests default impo…
…rt mode going forward isn't certain so avoiding relative imports with pytest seems more extensible pytest docs on this:https://docs.pytest.org/en/stable/goodpractices.html#tests-outside-application-code. Pytest dev branch discussion around this: pytest-dev/pytest#7245 AND pytest-dev/pytest#7870
- Loading branch information
1 parent
8819e47
commit a7ee224
Showing
7 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env python | ||
import uuid | ||
import sys | ||
|
||
import click | ||
|
||
from jobcoin import jobcoin | ||
|
||
|
||
@click.command() | ||
def main(args=None): | ||
print('Welcome to the Jobcoin mixer!\n') | ||
while True: | ||
addresses = click.prompt( | ||
'Please enter a comma-separated list of new, unused Jobcoin ' | ||
'addresses where your mixed Jobcoins will be sent.', | ||
prompt_suffix='\n[blank to quit] > ', | ||
default='', | ||
show_default=False) | ||
if addresses.strip() == '': | ||
sys.exit(0) | ||
deposit_address = uuid.uuid4().hex | ||
click.echo( | ||
'\nYou may now send Jobcoins to address {deposit_address}. They ' | ||
'will be mixed and sent to your destination addresses.\n' | ||
.format(deposit_address=deposit_address)) | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Replace the URL below | ||
API_BASE_URL = 'http://jobcoin.gemini.com/undaunted-gossip/api' | ||
API_ADDRESS_URL = '{}/addresses'.format(API_BASE_URL) | ||
API_TRANSACTIONS_URL = '{}/transactions'.format(API_BASE_URL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from . import config | ||
|
||
# Write your Jobcoin API client here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
click==7.0 | ||
pytest==6.2.2 | ||
requests==2.20.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env python | ||
import pytest | ||
import re | ||
from click.testing import CliRunner | ||
|
||
|
||
from jobcoin import config | ||
import cli | ||
|
||
|
||
@pytest.fixture | ||
def response(): | ||
import requests | ||
return requests.get('https://jobcoin.gemini.com/') | ||
|
||
|
||
def test_content(response): | ||
assert 'Hello!' in response.text | ||
|
||
|
||
def test_cli_basic(): | ||
runner = CliRunner() | ||
result = runner.invoke(cli.main) | ||
assert result.exit_code == 0 | ||
assert 'Welcome to the Jobcoin mixer' in result.output | ||
|
||
|
||
def test_cli_creates_address(): | ||
runner = CliRunner() | ||
address_create_output = runner.invoke(cli.main, input='1234,4321').output | ||
output_re = re.compile( | ||
r'You may now send Jobcoins to address [0-9a-zA-Z]{32}. ' | ||
'They will be mixed and sent to your destination addresses.' | ||
) | ||
assert output_re.search(address_create_output) is not None |