Skip to content

Commit f69ce1c

Browse files
committed
a little clarification of the unit tested mailroom
1 parent d29ef29 commit f69ce1c

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

source/exercises/mailroom/mailroom_with_tests.rst

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,24 @@ For unit testing framework you should use `pytest <https://docs.pytest.org/en/la
3535
Mailroom Code Structure
3636
-----------------------
3737

38-
Your code should have 3 main features so far:
38+
Your code should have 2 main features so far:
3939

4040
* Send a thank you (adds a new donor or updates existing donor info)
4141
* Create a report
42-
* Send letters (creates files)
4342

4443

4544
Send Thank You
4645
...............
4746

4847
Even though every mailroom implementation will be unique, most likely this function will require a significant refactor for most of you.
49-
You can break up the code into components that handle user interaction and data manipulation logic. Your unit tests should test the data manipulation logic code: generating the thank you text, adding or updating donors, and listing donors.
48+
49+
You can break up the code into components that handle user interaction and data manipulation logic. Your unit tests should test the data manipulation logic code:
50+
51+
* generating the thank you text
52+
53+
* adding or updating donors
54+
55+
* listing donors
5056

5157

5258
Create Report
@@ -71,8 +77,14 @@ Here you would write a unit test for ``get_report`` function. Remember: TDD -- w
7177
Send Letters
7278
............
7379

74-
This function should require very little or no change to make it unit-testable.
80+
After adding unit tests, in a future assignment, you will be extending mailroom to save the thank you letters to files on disk.
81+
82+
Don't worry about that now -- but when you get there, keep testing in mind!
83+
84+
This function should be easy to make unit-testable.
85+
7586
To make it testable, you'll need to follow the same "separation of concerns" approach: the code that creates the letters should be separate from the code that prints them to the screen.
87+
7688
This both allows you to test the letter creation, and leaves the door open to do something else with the letters: save to to a file, send as an email, etc.
7789
So the code that makes a letter likely will return a string with the entire letter contents.
7890

@@ -106,7 +118,7 @@ But trust me -- that is a Good Thing™
106118

107119
.. note:: Testing print() is rearely neccesasry if you factor your code correctly. But it would be able to test your menu code with `input()` in it. This is a pretty advanced topic, but if you want to give it a try, there is more on advanced testing here: :ref:`advanced_testing`
108120

109-
121+
110122

111123

112124

0 commit comments

Comments
 (0)