Skip to content

Commit

Permalink
added codeforces_test file
Browse files Browse the repository at this point in the history
  • Loading branch information
Shraman-jain committed May 31, 2024
1 parent 4f91bd4 commit 9e066da
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/test/codechef_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ def test_get_profile(self):


if __name__ == "__main__":
unittest.main()
unittest.main()
50 changes: 50 additions & 0 deletions src/test/codeforces_test.py
Original file line number Diff line number Diff line change
@@ -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",
)


2 changes: 1 addition & 1 deletion src/test/hackerrank_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down

0 comments on commit 9e066da

Please sign in to comment.