From 6e1cd83bf00822e73a35b1ed6a660c0f3f389f00 Mon Sep 17 00:00:00 2001 From: andrew0022 Date: Mon, 6 Nov 2023 15:51:40 -0500 Subject: [PATCH 1/2] rice country --- src/riceinfo/rice.py | 24 +++++++++++++++++++ tests/test_riceCountry.py | 50 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 tests/test_riceCountry.py diff --git a/src/riceinfo/rice.py b/src/riceinfo/rice.py index aa03932..d906f0f 100644 --- a/src/riceinfo/rice.py +++ b/src/riceinfo/rice.py @@ -43,6 +43,30 @@ def tellPun(punType: Pun) -> str: return random.choice(punsDict[Pun.RHYME]) case default: return "not a valid PUN TYPE" + + def riceCountry(country_name): + country_name = country_name.lower() + + rice_country = { + 'brazil': 'Brazillian markets often sell a traditional variety of a short-grain rice called Arborio, which is commonly used for risotto.', + 'egypt': 'Egypt consumes a variety of different rice, including Japonica, but is most known for Giza 178 rice, a medium-grain variety that is commonly used in traditional Egyptian dishes.', + 'mexico': 'Mexico often uses a long-grain Patna rice, which is known for its long kernel and grain length.', + 'nigeria': 'Nigeria primarily uses Ofada rice, which is an indigenous rice that consists mostly of blends containing African rice.', + 'china': 'China is a major consumer of traditional jasmine rice, though they use many different varieties of short, medium, and long grain rice, depending on the dish.', + 'thailand': 'Thailand is famous for its fragrant Jasmine rice, which is a long-grain rice variety known for its unique aroma and flavor.', + 'indonesia': 'Indonesia commonly uses Pandan rice, which is jasmine rice cooked in pandan leaves and is used in dishes like Nasi Goreng.', + 'japan': 'Japan primarily uses a short grain Koshihikari rice for sushi, sashimi, and traditional Japanese dishes.', + 'south korea': 'South Korea mainly uses Calrose rice, a medium grain variety which is used for dishes like Bibimbap and Kimbap.' + } + + while country_name not in rice_country: + print("Error: Invalid country name. Please choose from the following options:") + for option in rice_country: + print(option.capitalize()) + country_name = input("Please enter a valid country name: ").lower() + + print(rice_country[country_name]) + def history(century): if century == 1: diff --git a/tests/test_riceCountry.py b/tests/test_riceCountry.py new file mode 100644 index 0000000..2b9c51b --- /dev/null +++ b/tests/test_riceCountry.py @@ -0,0 +1,50 @@ +from src.riceinfo.rice import riceinfo +import pytest + +class Tests: + ## python -m pytest + def test_brazil(self): + testcase = riceinfo.riceCountry("brazil") + expected = 'Brazillian markets often sell a traditional variety of a short-grain rice called Arborio, which is commonly used for risotto.' + assert isinstance(testcase, str), f"Expected riceCountry() to return a string. Instead it returned a {testcase}" + assert testcase == expected + def test_egypt(self): + testcase = riceinfo.riceCountry("egypt") + expected = 'Egypt consumes a variety of different rice, including Japonica, but is most known for Giza 178 rice, a medium-grain variety that is commonly used in traditional Egyptian dishes.' + assert isinstance(testcase, str), f"Expected riceCountry() to return a string. Instead it returned a {testcase}" + assert testcase == expected + def test_mexico(self): + testcase = riceinfo.riceCountry("mexico") + expected = 'Mexico often uses a long-grain Patna rice, which is known for its long kernel and grain length.' + assert isinstance(testcase, str), f"Expected riceCountry() to return a string. Instead it returned a {testcase}" + assert testcase == expected + def test_nigeria(self): + testcase = riceinfo.riceCountry("nigeria") + expected = 'Nigeria primarily uses Ofada rice, which is an indigenous rice that consists mostly of blends containing African rice.' + assert isinstance(testcase, str), f"Expected riceCountry() to return a string. Instead it returned a {testcase}" + assert testcase == expected + def test_china(self): + testcase = riceinfo.riceCountry("china") + expected = 'China is a major consumer of traditional jasmine rice, though they use many different varieties of short, medium, and long grain rice, depending on the dish.' + assert isinstance(testcase, str), f"Expected riceCountry() to return a string. Instead it returned a {testcase}" + assert testcase == expected + def test_thailand(self): + testcase = riceinfo.riceCountry("thailand") + expected = 'Thailand is famous for its fragrant Jasmine rice, which is a long-grain rice variety known for its unique aroma and flavor.' + assert isinstance(testcase, str), f"Expected riceCountry() to return a string. Instead it returned a {testcase}" + assert testcase == expected + def test_indonesia(self): + testcase = riceinfo.riceCountry("indonesia") + expected = 'Indonesia commonly uses Pandan rice, which is jasmine rice cooked in pandan leaves and is used in dishes like Nasi Goreng.' + assert isinstance(testcase, str), f"Expected riceCountry() to return a string. Instead it returned a {testcase}" + assert testcase == expected + def test_japan(self): + testcase = riceinfo.riceCountry("japan") + expected = 'Japan primarily uses a short grain Koshihikari rice for sushi and other traditional Japanese dishes.' + assert isinstance(testcase, str), f"Expected riceCountry() to return a string. Instead it returned a {testcase}" + assert testcase == expected + def test_south_korea(self): + testcase = riceinfo.riceCountry("south korea") + expected = 'South Korea mainly uses Calrose rice, a medium grain variety which is used for dishes like Bibimbap and Kimbap.' + assert isinstance(testcase, str), f"Expected riceCountry() to return a string. Instead it returned a {testcase}" + assert testcase == expected \ No newline at end of file From 8447241e3210024c0224ff62b4deaca46d4268c2 Mon Sep 17 00:00:00 2001 From: andrew0022 Date: Mon, 6 Nov 2023 15:59:23 -0500 Subject: [PATCH 2/2] fix return --- src/riceinfo/rice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/riceinfo/rice.py b/src/riceinfo/rice.py index d906f0f..4cad027 100644 --- a/src/riceinfo/rice.py +++ b/src/riceinfo/rice.py @@ -55,7 +55,7 @@ def riceCountry(country_name): 'china': 'China is a major consumer of traditional jasmine rice, though they use many different varieties of short, medium, and long grain rice, depending on the dish.', 'thailand': 'Thailand is famous for its fragrant Jasmine rice, which is a long-grain rice variety known for its unique aroma and flavor.', 'indonesia': 'Indonesia commonly uses Pandan rice, which is jasmine rice cooked in pandan leaves and is used in dishes like Nasi Goreng.', - 'japan': 'Japan primarily uses a short grain Koshihikari rice for sushi, sashimi, and traditional Japanese dishes.', + 'japan': 'Japan primarily uses a short grain Koshihikari rice for sushi and other traditional Japanese dishes.', 'south korea': 'South Korea mainly uses Calrose rice, a medium grain variety which is used for dishes like Bibimbap and Kimbap.' } @@ -65,7 +65,7 @@ def riceCountry(country_name): print(option.capitalize()) country_name = input("Please enter a valid country name: ").lower() - print(rice_country[country_name]) + return (rice_country[country_name]) def history(century):