This repository has been archived by the owner on Apr 4, 2024. It is now read-only.
forked from diffplug/selfie
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
silly python function and test (#13)
- Loading branch information
Showing
3 changed files
with
39 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
from .ned import fizzbuzz as fizzbuzz | ||
|
||
from .selina import get_interesting_fact as get_interesting_fact | ||
from .harvir import silly_addition as silly_addition | ||
from .edwin import simple_subtraction as simple_subtraction | ||
from .edwin import simple_subtraction as simple_subtraction |
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,15 @@ | ||
def get_interesting_fact(category): | ||
facts = { | ||
"science": "Honey never spoils. Archaeologists have found pots of honey in ancient Egyptian tombs that are over 3,000 years old and still perfectly edible.", | ||
"history": "The shortest war in history lasted only 38 minutes. It was between Britain and Zanzibar on August 27, 1896.", | ||
"animals": "Penguins only have one mate their entire life. They also propose to their lifemates with a pebble.", | ||
"technology": "The first computer virus was created in 1983 and was called the 'Elk Cloner'. It infected Apple II computers via floppy disks." | ||
} | ||
|
||
category_lower = category.lower() | ||
if category_lower in facts: | ||
return facts[category_lower] | ||
else: | ||
return "Sorry, I don't have an interesting fact for that category." | ||
|
||
|
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,21 @@ | ||
from selfie_lib import get_interesting_fact | ||
|
||
def test_science_fact(): | ||
fact = get_interesting_fact("science") | ||
assert fact == "Honey never spoils. Archaeologists have found pots of honey in ancient Egyptian tombs that are over 3,000 years old and still perfectly edible." | ||
|
||
def test_history_fact(): | ||
fact = get_interesting_fact("history") | ||
assert fact == "The shortest war in history lasted only 38 minutes. It was between Britain and Zanzibar on August 27, 1896." | ||
|
||
def test_animals_fact(): | ||
fact = get_interesting_fact("animals") | ||
assert fact == "Penguins only have one mate their entire life. They also propose to their lifemates with a pebble." | ||
|
||
def test_technology_fact(): | ||
fact = get_interesting_fact("technology") | ||
assert fact == "The first computer virus was created in 1983 and was called the 'Elk Cloner'. It infected Apple II computers via floppy disks." | ||
|
||
def test_invalid_category(): | ||
fact = get_interesting_fact("invalid") | ||
assert fact == "Sorry, I don't have an interesting fact for that category." |