forked from seanshoffman/python-build-cli-planner-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ReTeam Labs
committed
May 5, 2020
1 parent
504627a
commit 6e10e78
Showing
7 changed files
with
84 additions
and
22 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# python-build-cli-planner-app | ||
|
||
In this project you will implement a simple reminder app with a command line interface (CLI). While doing so, you will learn how to use inheritance and abstract base classes to make your code modular and to ensure a contract between your classes. | ||
|
||
First, we will guide you through implementing simple text reminders. Then, you will have reminders with a deadline, which is either a date, or a date and a time. As each of these have their own class, you will see how these can play together nicely. This basis makes it easy for you to go beyond the course scope and implement other types of reminders, such as recurrent ones. | ||
|
||
## Setup | ||
|
||
You should have [Docker](https://www.docker.com/products/docker-desktop) installed, as well as `make`. These ensure the app is easy to run regardless of your platform. | ||
|
||
### Play with the app | ||
|
||
Now that you have all the requirements ready, you can test the app by running `make` in the root directory. You can add a new reminder, or list the ones you have already added. | ||
|
||
Try adding a couple of reminders, such as *Drink water*, *Take a break* or *Buy some milk*. | ||
|
||
### Test the app | ||
|
||
To test your app, run `make test`. Since you have not implemented anything, all the tests should be failing. As you progress through the tasks, more and more of them will pass. When you are stuck, running the tests may give you a hint about your error. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pytest==5.3.5 | ||
python-dateutil==2.8.1 | ||
pytest-json-report==1.2.1 |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""This module implements some Reminder classes that we should | ||
consider as "external", whose source we do not control. | ||
""" | ||
from dateutil.parser import parse | ||
from collections.abc import Iterable | ||
|
||
class DateTimeReminder(Iterable): | ||
"""A reminder which has a specific date and time for being due""" | ||
def __init__(self, text: str, date: str, time: str = '9am'): | ||
self.text = text | ||
self.date = parse(f'{date} {time}') | ||
self.time = self.date.time() | ||
|
||
def __iter__(self): | ||
return iter([self.text, | ||
self.date.strftime("%m/%d/%YT%H:%M:%SZ"), | ||
self.time.strftime('%I:%M %p')]) | ||
|
||
def is_due(self): | ||
return self.date < datetime.now() | ||
|
||
|
||
class MorningReminder(DateTimeReminder): | ||
"""A reminder that is due at 9am""" | ||
def __init__(self, text: str, date: str): | ||
super().__init__(text, date, '9am') | ||
|
||
class EveningReminder(DateTimeReminder): | ||
"""A reminder that is due at 8pm""" | ||
def __init__(self, text: str, date: str): | ||
super().__init__(text, date, '8pm') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class PrefixedReminder: | ||
"""This class acts as a base class for other types of reminders. | ||
Classes that subclass it should override the `self.text` property | ||
""" | ||
def __init__(self, prefix="Hey, don't forget to "): | ||
self.prefix = prefix | ||
self.text = prefix + '<placeholder_text>' |