Username/AccessToken provided via Environment variables #13

Merged
merged 1 commit into from Jan 11, 2013

Projects

None yet

2 participants

@ianozsvald
Contributor

Username and AccessToken are imported using environment variables. If they're missing then a useful error is raised. README updated to explain how to set this up, doc added in test_bitly_api.py to explain how to run the test.

One test changed in test_bitly_api as the 'test1' key is a valid bitly key, maybe this entered the keyspace? I've added a longer random string, I don't know if this keeps the same meaning to the test (this needs validation).

@jehiah jehiah and 1 other commented on an outdated diff Jan 11, 2013
test/test_bitly_api.py
import sys
sys.path.append('../')
import bitly_api
+BITLY_USERNAME = "BITLY_USERNAME"
+BITLY_ACCESS_TOKEN = "BITLY_ACCESS_TOKEN"
+
+def get_connection():
+ """Create a Connection base on username and access token credentials"""
+ if BITLY_USERNAME not in os.environ:
jehiah
jehiah Jan 11, 2013 Owner

when using an OAuth access token, this bitly_username is completely ignored. The tests pass for me w/o that, so i think if you drop that block of code we'll be good to go.

ianozsvald
ianozsvald Jan 11, 2013 Contributor

Good spot - have removed, also tidied some pep8 points.

Owner
jehiah commented Jan 11, 2013

awesome. changes look good.

before merging, we prefer to squash changes down to a single commit. Would you mind doing that here?

Contributor

You're welcome to try on my behalf, this is beyond my git-fu. I tried this https://github.com/ginatrapani/todo.txt-touch/wiki/Squash-All-Commits-Related-to-a-Single-Issue-into-a-Single-Commit and now I have HEAD, develop and two other branches, all in broken states. You're welcome to take my changes and merge them under your own user if that's easier.

Owner
jehiah commented Jan 11, 2013

sorry, yeah, squashing is annoying sometimes.

The workflow I normally use to squash is

# add bitly as a remote (if you don't have it already)
$ git remote add bitly https://github.com/bitly/bitly-api-python.git
$ git fetch bitly
# interactive rebase; leaving the first commit with 'pick' and switching the rest to 'squash'
$ git rebase --interactive bitly/master

Then after a successful squash, it obviously requires a force push up to github because history has changed.

If you want to try again after restting hard to your remote (git reset --hard origin/master) go ahead, otherwise i'll be happy to push a squashed commit to your branch and we can close this out.

@ianozsvald ianozsvald testExpand required a new key (test1 existed in bitly)\, all 4 method…
…s now use get_connection to fetch user credentials from environment variables

updated doc to include notes on running the tests

updated doc to include notes on running the tests

removed unnecessary username

pep8 pedantry
f98f3e4
Contributor

Ok, I tried:
$ mv bitly-api-python bitly-api-python-bitbarfed # push old out of the way
$ git clone git@github.com:ianozsvald/bitly-api-python.git # get fresh copy
$ git rebase -i HEAD~5 # following https://github.com/ginatrapani/todo.txt-touch/wiki/Squash-All-Commits-Related-to-a-Single-Issue-into-a-Single-Commit
pick 499454a testExpand required a new key (test1 existed in bitly), all 4 methods now use get_connection to fetch user credentials from environment variables
squash aeb9e42 updated doc to include notes on running the tests
squash 090bff9 updated doc to include notes on running the tests
squash b7a2db4 removed unnecessary username
squash 6dd6a47 pep8 pedantry
I changed the last 4 from 'pick' to 'squash'
$ $ git push origin master --force # force it up (I missed this step before)

It looks like it works, please confirm?

@jehiah jehiah merged commit 11a2d9c into bitly:master Jan 11, 2013
Owner
jehiah commented Jan 11, 2013

that did it. thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment