Story points | 8 |
Tags | mocks smtp apis json command-line parameters errors |
Hard Prerequisites | |
IMPORTANT: Please review these prerequisites, they include important information that will help you with this content. | |
|
Upgrade your project so that it can accept either an email address or a file path as a command line argument.
For example:
# if you are writing python:
python send_inspiration.py ~/email_recipients.json
# if you are writing javascript:
npm run send_inspiration ~/email_recipients.json
# if you are writing Java
java SendInspiration ~/email_recipients.json
The file path should point to a json file with the following format:
[
{
"email": "someone@email.com",
"name": "Tshepo"
},
{
"email": ...
"name": ...
},
{...},
...
]
The script should send an email to each of the email addresses above.
The email should include the name of the person who is receiving the email. For example:
Dear Tshepo,
"It is good even for old men to learn wisdom." - Aeschylus
Sometimes you will want to send exactly the same quote to every single person in the mailing list. And sometimes you’ll want to send a different quote to each person. We will also make use of a command-line argument to control this.
The default behavior will be that everyone gets a different random quote.
The following will result in each recipient getting the exact same quote:
# if you are writing python:
python send_inspiration.py ~/email_recipients.json --same
# if you are writing javascript:
npm run send_inspiration ~/email_recipients.json -- --same
# if you are writing Java
java SendInspiration ~/email_recipients.json --same
Please raise/throw an appropriate error/exception in these situations:
Please make sure that your original functionality does not break. Ideally your unit tests for the original functionality will not need to change.
As usual, test your work well. You will need to make sure that you are using mocks/spies to test this work.