diff --git a/src/test/codechef_test.py b/src/test/codechef_test.py index a58e8aaa..fede8d22 100644 --- a/src/test/codechef_test.py +++ b/src/test/codechef_test.py @@ -22,4 +22,4 @@ def test_get_profile(self): if __name__ == "__main__": - unittest.main() + unittest.main() diff --git a/src/test/codeforces_test.py b/src/test/codeforces_test.py new file mode 100644 index 00000000..4b649a90 --- /dev/null +++ b/src/test/codeforces_test.py @@ -0,0 +1,50 @@ +import unittest +from scrape_up import codeforces + +class CodeforcesTest(unittest.TestCase): + """ + Codeforces module test.\n + | Methods | Details | + | ----------------------------- | ---------------------------------------------------------------- | + | `get_user_data(username)` | Fetches user data from CodeForces. | + | `get_contests()` | Returns information on active and past contests like title, start, and duration | + """ + + def test_get_user_data(self): + instance = codeforces.Users(username="tourist") + method_response = instance.get_user_data() + + self.assertEqual( + list(method_response.keys()), + [ + "rank", + "handle", + "firstname", + "lastname", + "city", + "country", + "organization", + "rating", + "contribution", + "friendsofcount", + "lastvisit", + "registered", + "titlephoto", + "avatar" + ], + "Codeforces:get_user_data - keys mismatch", + ) + def test_get_contests(self): + instance = codeforces.Contest() + method_response = instance.get_contests() + + self.assertEqual( + list(method_response.keys()), + [ + "upcoming_contest", + "ended_contest" + ], + "Codeforces:get_contests - keys mismatch", + ) + + diff --git a/src/test/hackerrank_test.py b/src/test/hackerrank_test.py index 05908e20..aa7081d2 100644 --- a/src/test/hackerrank_test.py +++ b/src/test/hackerrank_test.py @@ -4,7 +4,7 @@ class HackerrankTest(unittest.TestCase): """ - CodeChef module test.\n + Hackerrank module test.\n | Methods | Details | | ----------------------------- | ---------------------------------------------------------------- | | `get_profile(id="username")` | Returns name, username, country, user_type, details, badges, verified_skills, social etc. |