-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1180 from timponce/master
Implement Issue #1179 - Tests for Leap Year Plugin
- Loading branch information
Showing
2 changed files
with
52 additions
and
14 deletions.
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
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,35 @@ | ||
import unittest | ||
from tests import PluginTest | ||
from plugins import leap_year | ||
|
||
|
||
class LeapYearTest(PluginTest): | ||
def setUp(self): | ||
self.test = self.load_plugin(leap_year.leap_year) | ||
|
||
def test_divisible_by_400_and_100(self): | ||
self.test.run("2000") | ||
self.assertEqual(self.history_say().last_text(), "2000 is a leap year.") | ||
|
||
def test_divisible_by_100_and_not_400(self): | ||
self.test.run("1900") | ||
self.assertEqual(self.history_say().last_text(), "1900 is not a leap year.") | ||
|
||
def test_divisible_by_4_and_not_100(self): | ||
self.test.run("2008") | ||
self.assertEqual(self.history_say().last_text(), "2008 is a leap year.") | ||
|
||
def test_not_divisible_by_4(self): | ||
self.test.run("2017") | ||
self.assertEqual(self.history_say().last_text(), "2017 is not a leap year.") | ||
|
||
def test_invalid_input(self): | ||
self.test.run("abc") | ||
self.assertEqual( | ||
self.history_say().last_text(), | ||
"Wrong input. Please make sure you just enter an integer e.g. '2012'.", | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |