-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
9dc8a07
commit 77c42a3
Showing
9 changed files
with
108 additions
and
26 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,3 @@ | ||
[run] | ||
include = | ||
marvelous/* |
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
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,42 @@ | ||
import os | ||
import unittest | ||
|
||
import marvelous | ||
|
||
|
||
class NoGet: | ||
def store(self, key, value): | ||
# This method should store key value pair | ||
return | ||
|
||
|
||
class NoStore: | ||
def get(self, key): | ||
# This method should return cahed value with key | ||
return None | ||
|
||
|
||
class TestComics(unittest.TestCase): | ||
def setUp(self): | ||
self.pub = os.getenv('PUBLIC_KEY', 'pub') | ||
self.priv = os.getenv('PRIVATE_KEY', 'priv') | ||
|
||
def test_no_get(self): | ||
m = marvelous.api( | ||
public_key=self.pub, private_key=self.priv, | ||
cache=NoGet()) | ||
|
||
with self.assertRaises(marvelous.exceptions.CacheError): | ||
m.series(466) | ||
|
||
def test_no_store(self): | ||
m = marvelous.api( | ||
public_key=self.pub, private_key=self.priv, | ||
cache=NoStore()) | ||
|
||
with self.assertRaises(marvelous.exceptions.CacheError): | ||
m.series(466) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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,35 @@ | ||
import os | ||
import unittest | ||
|
||
import marvelous | ||
from marvelous.comics_list import ComicsList | ||
|
||
|
||
class TestComics(unittest.TestCase): | ||
def setUp(self): | ||
pub = os.getenv('PUBLIC_KEY', 'pub') | ||
priv = os.getenv('PRIVATE_KEY', 'priv') | ||
self.m = marvelous.api( | ||
public_key=pub, private_key=priv, | ||
cache=marvelous.SqliteCache("tests/testing_mock.sqlite")) | ||
|
||
def test_known_series(self): | ||
usms = self.m.series(466) | ||
self.assertTrue(usms.title == "Ultimate Spider-Man (2000 - 2009)") | ||
self.assertTrue(usms.id == 466) | ||
comics = usms.comics() | ||
self.assertTrue(comics[0].id == 23931) | ||
|
||
self.assertTrue(len(comics[:5]) == 5) | ||
self.assertTrue(len(comics) == len([x for x in comics if x.id > 3])) | ||
|
||
def test_bad_series(self): | ||
with self.assertRaises(marvelous.exceptions.ApiError): | ||
self.m.series(-1) | ||
|
||
def test_bad_response_data(self): | ||
with self.assertRaises(marvelous.exceptions.ApiError): | ||
ComicsList({'data': {'results': [{'modified': 'potato'}]}}) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Binary file not shown.