Last active
February 23, 2016 21:17
-
-
Save blaix/f5e2834f5f4d01111110 to your computer and use it in GitHub Desktop.
This file contains hidden or 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) |
Author
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_tokenis now all about the logic. So the tests can just pass in dicts and assert agains the==check.validate_token_for_yola_useris now all about collaboration. This is where mocks should be used. The tests should mockYolaandvalidate_tokenand assertget_userandget_partnerandvalidate_tokenare called correctly.