Skip to content

Commit

Permalink
Create test_voting_age.py
Browse files Browse the repository at this point in the history
unit test for my first challenge
  • Loading branch information
ajfumero8 authored Jan 11, 2025
1 parent 8d22cdf commit 52d13df
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions solutions/tests/test_voting_age.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import unittest

min_age = 18

participants = {
'jackson': {'age': 18},
'bob': {'age': 40},
'charlotte': {'age': 17},
'marley': {'age': 28},
'erica': {'age': 6},
}

def can_vote(person):
return person['age'] >= min_age

class TestCanVote(unittest.TestCase):
def test_exact_age(self):
"""Test if a person exactly at the voting age is eligible."""
jackson = participants['jackson']
self.assertTrue(can_vote(jackson))

def test_above_voting_age(self):
"""Test if a person above the voting age is eligible."""
bob = participants['bob']
self.assertTrue(can_vote(bob))

def test_below_voting_age(self):
"""Test if a person below the voting age is not eligible."""
charlotte = participants['charlotte']
self.assertFalse(can_vote(charlotte))

def test_far_below_voting_age(self):
"""Test if a person far below the voting age is not eligible."""
erica = participants['erica']
self.assertFalse(can_vote(erica))

if __name__ == "__main__":
unittest.main()

0 comments on commit 52d13df

Please sign in to comment.