-
Write a simple Promo class. Its constructor receives two variables: name (which must be a string) and expires (which must be a datetime object).
-
Add a property called expired which returns a boolean value indicating whether the promo has expired or not.
from datetime import datetime, timedelta
NOW = datetime.now()
class Promo:
def __init__(self, name, expires):
self.name = str(name)
self.expires = expires
@property
def expired(self):
if self.expires < NOW:
return True
return False
Write tests for:
- Check output with promo expired
- Check output with promo not expired
- Check if property is used in the Promo class