Skip to content

Instantly share code, notes, and snippets.

@jugmac00
Last active January 29, 2020 07:08
Show Gist options
  • Save jugmac00/4ede04dda92b9e14fd7318ae2bf7fb34 to your computer and use it in GitHub Desktop.
Save jugmac00/4ede04dda92b9e14fd7318ae2bf7fb34 to your computer and use it in GitHub Desktop.
No need for mocking?
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