Skip to content

Commit 76b6c24

Browse files
author
Alan Tan
committed
Add doctest for 3-tier
1 parent 8ff7ae4 commit 76b6c24

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

patterns/structural/3-tier.py

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -61,32 +61,36 @@ def get_product_information(self, product: str) -> None:
6161

6262

6363
def main():
64-
ui = Ui()
65-
ui.get_product_list()
66-
ui.get_product_information("cheese")
67-
ui.get_product_information("eggs")
68-
ui.get_product_information("milk")
69-
ui.get_product_information("arepas")
70-
64+
"""
65+
>>> ui = Ui()
66+
>>> ui.get_product_list()
67+
PRODUCT LIST:
68+
(Fetching from Data Store)
69+
milk
70+
eggs
71+
cheese
72+
<BLANKLINE>
73+
74+
>>> ui.get_product_information("cheese")
75+
(Fetching from Data Store)
76+
PRODUCT INFORMATION:
77+
Name: Cheese, Price: 2.00, Quantity: 10
78+
79+
>>> ui.get_product_information("eggs")
80+
(Fetching from Data Store)
81+
PRODUCT INFORMATION:
82+
Name: Eggs, Price: 0.20, Quantity: 100
83+
84+
>>> ui.get_product_information("milk")
85+
(Fetching from Data Store)
86+
PRODUCT INFORMATION:
87+
Name: Milk, Price: 1.50, Quantity: 10
88+
89+
>>> ui.get_product_information("arepas")
90+
(Fetching from Data Store)
91+
That product 'arepas' does not exist in the records
92+
"""
7193

7294
if __name__ == "__main__":
73-
main()
74-
75-
### OUTPUT ###
76-
# PRODUCT LIST:
77-
# (Fetching from Data Store)
78-
# cheese
79-
# eggs
80-
# milk
81-
#
82-
# (Fetching from Data Store)
83-
# PRODUCT INFORMATION:
84-
# Name: Cheese, Price: 2.00, Quantity: 10
85-
# (Fetching from Data Store)
86-
# PRODUCT INFORMATION:
87-
# Name: Eggs, Price: 0.20, Quantity: 100
88-
# (Fetching from Data Store)
89-
# PRODUCT INFORMATION:
90-
# Name: Milk, Price: 1.50, Quantity: 10
91-
# (Fetching from Data Store)
92-
# That product "arepas" does not exist in the records
95+
import doctest
96+
doctest.testmod()

0 commit comments

Comments
 (0)