-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
40 lines (31 loc) · 1.06 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
Test module for get_comments.py
"""
import argparse
from collections.abc import Coroutine
import unittest
import httpx
from get_comments import parser, get_bio # pylint: disable=import-error
class TestGetComments(unittest.TestCase):
"""Example unittest test methods for get_comments"""
def test_get_bio(self):
"""Should return a coroutine after hitting the internet"""
username = "morenoh149"
client = httpx.AsyncClient()
bio = get_bio(username, client)
self.assertIsInstance(bio, Coroutine)
def test_valid_args(self):
"""Test that the tool accepts valid story_id"""
cmd_args = "35759449 ".split()
args = parser().parse_args(cmd_args)
assert isinstance(args, argparse.Namespace)
def test_invalid_args(self):
"""Test that the tool complains about invalid story_id"""
cmd_args = "abc ".split()
try:
parser().parse_args(cmd_args)
return True
except SystemExit:
return False
if __name__ == '__main__':
unittest.main()