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
Daniel
committed
Mar 3, 2017
1 parent
11832e5
commit 2cc0ddd
Showing
11 changed files
with
121 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[run] | ||
branch = True | ||
source = psraw | ||
include = psraw/*.py |
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 |
---|---|---|
|
@@ -84,5 +84,3 @@ ENV/ | |
|
||
# Spyder project settings | ||
.spyderproject | ||
|
||
test.py |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
language: python | ||
python: | ||
- "2.7" | ||
- "3.6" | ||
install: source ./ci/travis_install.sh | ||
script: bash ./ci/travis_test.sh | ||
cache: apt | ||
sudo: false | ||
after_success: | ||
- coveralls |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
pip install praw | ||
pip install nose | ||
pip install coverage coveralls | ||
|
||
python --version | ||
python -c "import praw; print('praw %s' % praw.__version__)" | ||
python setup.py build_ext --inplace |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
python --version | ||
python -c "import praw; print('praw %s' % praw.__version__)" | ||
nosetests -sv --with-coverage |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from test.test_endpoints import * | ||
from test.test_helpers import * |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import praw | ||
import psraw | ||
from psraw.endpoints import ENDPOINTS, sort_type | ||
|
||
|
||
def test_psraw_exports(): | ||
"""psraw exports a function for every endpoint specified in ENDPOINTS""" | ||
endpoint_names = set(ENDPOINTS.keys()) | ||
psraw_exports = set(dir(psraw)) | ||
assert endpoint_names.issubset(psraw_exports) |
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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import praw | ||
from psraw.base import limit_chunk, coerce_kwarg_types | ||
from psraw.endpoints import ENDPOINTS, sort_type | ||
|
||
|
||
test_config = { | ||
'params': { | ||
'foo': str, | ||
'bar': int | ||
}, | ||
'return_type': praw.models.Comment, | ||
'url': '/foo/bar' | ||
} | ||
|
||
|
||
def test_limit_chunk_1(): | ||
"""limit_chunk returns an array as expected with two positive arguments""" | ||
chunks = limit_chunk(333, 100) | ||
assert chunks == [100, 100, 100, 33] | ||
|
||
|
||
def test_limit_chunk_2(): | ||
"""limit_chunk raises a ValueError when given a limit_max < 1""" | ||
try: | ||
limit_chunk(100, 0) | ||
assert False | ||
except ValueError: | ||
pass | ||
|
||
|
||
def test_limit_chunk_3(): | ||
"""limit_chunk returns an empty list if limit is < 1""" | ||
chunks = limit_chunk(-1, 100) | ||
assert chunks == [] | ||
|
||
|
||
def test_coerce_kwarg_types_1(): | ||
"""coerce_kwarg_types raises a ValueError when passed an unspecified argument""" | ||
try: | ||
kwargs = {'foobar': 24} | ||
coerced_kwargs = coerce_kwarg_types(kwargs, test_config['params']) | ||
assert False | ||
except ValueError: | ||
pass | ||
|
||
|
||
def test_coerce_kwarg_types_2(): | ||
"""coerce_kwarg_types converts parameter types""" | ||
kwargs = { | ||
'foo': 24, | ||
'bar': 25 | ||
} | ||
coerced_kwargs = coerce_kwarg_types(kwargs, test_config['params']) | ||
assert isinstance(coerced_kwargs['foo'], str) | ||
assert isinstance(coerced_kwargs['bar'], int) | ||
|
||
|
||
def test_sort_type_1(): | ||
"""sort_type returns the value passed in if it is a valid direction""" | ||
assert sort_type('asc') == 'asc' | ||
|
||
|
||
def test_sort_type_2(): | ||
"""sort_type raises a ValueError if the value passed in is not a direction""" | ||
try: | ||
sort_type('foobar') | ||
assert False | ||
except ValueError: | ||
pass |