-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
33 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
six | ||
requests | ||
fake_useragent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,40 @@ | ||
import requests | ||
from dcard.api import route | ||
|
||
try: | ||
from fake_useragent import UserAgent | ||
USER_AGENT = UserAgent().random | ||
except ImportError: | ||
USER_AGENT = ( | ||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) ' | ||
'Gecko/20100101 Firefox/64.0' | ||
) | ||
|
||
|
||
_post_id = 230004779 | ||
headers = {'User-Agent': USER_AGENT} | ||
|
||
|
||
def test_valid_api_forums(): | ||
url = route.forums() | ||
assert requests.get(url).ok | ||
assert requests.get(url, headers=headers).ok | ||
|
||
|
||
def test_valid_api_forum(): | ||
url = route.posts_meta(forum='funny') | ||
assert requests.get(url).ok | ||
assert requests.get(url, headers=headers).ok | ||
|
||
|
||
def test_valid_api_article(): | ||
url = route.post(post_id=_post_id) | ||
assert requests.get(url).ok | ||
assert requests.get(url, headers=headers).ok | ||
|
||
|
||
def test_valid_api_article_links(): | ||
url = route.post(post_id=_post_id, addition='links') | ||
assert requests.get(url).ok | ||
assert requests.get(url, headers=headers).ok | ||
|
||
|
||
def test_valid_api_article_comments(): | ||
url = route.post(post_id=_post_id, addition='comments') | ||
assert requests.get(url).ok | ||
assert requests.get(url, headers=headers).ok |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters