Last active
January 29, 2020 07:08
-
-
Save jugmac00/4ede04dda92b9e14fd7318ae2bf7fb34 to your computer and use it in GitHub Desktop.
No need for mocking?
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
from datetime import date | |
END_OF_EARLY_BIRD = date(2020, 6, 1) | |
def calculate_price(current_day): | |
# if today() > END_OF_EARLY_BIRD: | |
# no more call to today() => easy to test => no mock necessary | |
if current_day > END_OF_EARLY_BIRD: | |
return 1000 | |
else: | |
return 800 | |
def main(): | |
# huh - but what about this one? | |
price = calculate_price(current_day=date.today()) | |
print(f'You have to pay {price}') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment