Last active
February 23, 2016 21:17
-
-
Save blaix/f5e2834f5f4d01111110 to your computer and use it in GitHub Desktop.
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
def validate_token(secret, auth_token): | |
# do the token check logic... (using settings.PARTNER_ID) | |
def validate_token_from_yola(auth_token): | |
yola = Yola() | |
partner = yola.get_partner(settings.PARTNER_ID) | |
validate_token(partner['shared_secret_key'], auth_token) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's a good instinct. If you have places where collaboration and business logic mix, your tests are probably ugly, and a better design is probably hiding. In this gist I split that logic up:
validate_token
is now all about the logic. So the tests can just pass in dicts and assert agains the==
check.validate_token_for_yola_user
is now all about collaboration. This is where mocks should be used. The tests should mockYola
andvalidate_token
and assertget_user
andget_partner
andvalidate_token
are called correctly.