Skip to content

Commit

Permalink
Refactors amclient.py
Browse files Browse the repository at this point in the history
* Creates new logging configuration script to reduce redundancy
* Separates responsibility of amclient, defaults, and cli args
* Cleans up argparse output using metavar
* Adds Conformity to PEP8 to amclient.py and transfers.py
* Returns user friendly string via getattr if function call fails in main
* Improved error return from JSON request function in amclient.py
* Adds .db and .lck files to .gitignore
* Works at module and executable level
* E402 flake8 warning ignored in Tox to enable module/exe to work
* Captures connection errors in transfers.py better
* Initial changes provides scope for future refactoring as required
* Addresses #47
  • Loading branch information
ross-spencer committed Feb 21, 2018
1 parent 1cb44a7 commit 80d320b
Show file tree
Hide file tree
Showing 11 changed files with 658 additions and 426 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,14 @@
# Sublime files
*.sublime-*

# Log files
*.log.[0-9]
*.log

# Tox files
.tox/

# Script generated files
*.db
*.lck

1 change: 1 addition & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ metsrw==0.2.0
requests<3.0
sqlalchemy
six
urllib3
5 changes: 3 additions & 2 deletions tests/test_amclient.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python
"""To run the tests::
$ python -m unittest tests.test_amclient
Expand All @@ -11,6 +10,7 @@
import vcr

from transfers import amclient
from transfers import errors


AM_URL = 'http://192.168.168.192'
Expand All @@ -24,6 +24,7 @@


class TmpDir:

"""Context manager to clear and create a temporary directory and destroy it
after usage.
"""
Expand Down Expand Up @@ -118,7 +119,7 @@ def test_completed_transfers_bad_key(self):
completed_transfers = amclient.AMClient(
am_api_key='bad api key', am_user_name=AM_USER_NAME,
am_url=AM_URL).completed_transfers()
assert completed_transfers is None
assert completed_transfers is errors.ERR_INVALID_RESPONSE

@vcr.use_cassette(
'fixtures/vcr_cassettes/unapproved_transfers_transfers.yaml')
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ commands = flake8 .
exclude = .git, .tox, __pycache__, old, build, dist
ignore =
E501 # Lines are too long
E402 # Module level imports not at top of file
import-order-style = pep8
Loading

0 comments on commit 80d320b

Please sign in to comment.