def test_sort(self): """Test sort_batters() and sort_pitchers() with all parameters.""" hr_leaderboard = bst.sort_batters('HR', n=3, year='2017', min_ab=650) last_hitter = ('gordode', 2) self.assertEqual(hr_leaderboard[-1], last_hitter) so_leaderboard = bst.sort_pitchers('SO', n=3, year='2016', min_ip=227) last_pitcher = ('priceda', 228) self.assertEqual(so_leaderboard[-1], last_pitcher)
def test_sort_min(self): """Test sort_batters() and sort_pitchers() with a provided minimum.""" hit_leaderboard = bst.sort_batters('H', min_ab=236) last_hitter = ('lindofr', 61) self.assertEqual(hit_leaderboard[-1], last_hitter) era_leaderboard = bst.sort_pitchers('ERA', min_ip=80) last_pitcher = ('marquge', 3.75) self.assertEqual(era_leaderboard[-1], last_pitcher)
def test_sort_n(self): """Test sort_batters() and sort_pitchers() with provided n.""" hr_leaderboard = bst.sort_batters('HR', n=3) last_hitter = ('ozunama', 18) self.assertEqual(hr_leaderboard[-1], last_hitter) so_leaderboard = bst.sort_pitchers('SO', n=3) last_pitcher = ('bauertr', 100) self.assertEqual(so_leaderboard[-1], last_pitcher)
def test_sort_year(self): """Test sort_batters() and sort_pitchers() with provided year.""" hr_leaderboard = bst.sort_batters('HR', year='2018') hr_leader = ('daviskh', 48) self.assertEqual(hr_leaderboard[0], hr_leader) so_leaderboard = bst.sort_pitchers('SO', year='2018') so_leader = ('scherma', 300) self.assertEqual(so_leaderboard[0], so_leader)
def test_sort_metric_only(self): """Test sort_batters() and sort_pitchers() using only a metric.""" hr_leaderboard = bst.sort_batters('HR') hr_leader = ('voitlu0', 22) self.assertEqual(hr_leaderboard[0], hr_leader) so_leaderboard = bst.sort_pitchers('SO') so_leader = ('biebesh', 122) self.assertEqual(so_leaderboard[0], so_leader)