| 1 | import os |
| 2 | import sys |
| 3 | import unittest |
| 4 | |
| 5 | sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
| 6 | |
| 7 | from leaderboard import rank |
| 8 | |
| 9 | |
| 10 | class TestRank(unittest.TestCase): |
| 11 | def test_orders_by_score(self): |
| 12 | players = [("zora", 3), ("abel", 9)] |
| 13 | self.assertEqual(rank(players), [("abel", 9), ("zora", 3)]) |
| 14 | |
| 15 | def test_ties_keep_submission_order(self): |
| 16 | players = [("zora", 5), ("abel", 5), ("mira", 7)] |
| 17 | self.assertEqual(rank(players), [("mira", 7), ("zora", 5), ("abel", 5)]) |
| 18 | |
| 19 | |
| 20 | if __name__ == "__main__": |
| 21 | unittest.main() |
| 22 |