Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added codeforces_test file #1090

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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