forked from petercerno/good-morning
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
… and exception handling for passing empty string and invalid ticker symbol
- Loading branch information
Showing
5 changed files
with
190 additions
and
45 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,41 @@ | ||
language: python | ||
cache: pip | ||
matrix: | ||
include: | ||
- os: linux | ||
sudo: required | ||
python: 3.4 | ||
env: GDELT=py34 | ||
- os: linux | ||
sudo: required | ||
python: 3.5 | ||
env: GDELT=py35 | ||
- os: linux | ||
sudo: required | ||
python: 3.6 | ||
env: GDELT=py36 | ||
- os: osx | ||
language: generic | ||
env: GDELT=py34 | ||
- os: osx | ||
language: generic | ||
env: GDELT=py35 | ||
- os: osx | ||
language: generic | ||
env: GDELT=py36 | ||
|
||
install: | ||
- source travis/install.sh | ||
- 'pip install pip -U' | ||
- "pip install pytest-cov" | ||
script: | ||
- py.test --cov=./ | ||
|
||
cache: | ||
directories: | ||
- $HOME/.cache/pip | ||
before_cache: | ||
- rm -f $HOME/.cache/pip/log/debug.log | ||
|
||
after_success: | ||
- codecov |
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 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
|
||
from unittest import TestCase | ||
|
||
from morningstar import good_morning as gm | ||
from morningstar.good_morning import KeyRatiosDownloader | ||
|
||
class TestDownloadReturns(TestCase): | ||
def test_downloadreturn(self): | ||
kr = gm.KeyRatiosDownloader() | ||
frames = kr.download('aapl') | ||
test = len(frames) | ||
exp = 11 | ||
self.assertEqual(test, exp, "Download is working") | ||
|
||
def test_download_fail_empty(self): | ||
kr = gm.KeyRatiosDownloader() | ||
tickersym = '' | ||
exp = "You did not enter a ticker symbol. Please try again." | ||
with self.assertRaises(Exception) as context: | ||
checked = kr.download(tickersym) | ||
the_exception = context.exception | ||
return self.assertEqual(exp, str(the_exception), | ||
"Passing an empty string to " | ||
"good_morning fails") | ||
|
||
def test_download_fail_invalid(self): | ||
kr = gm.KeyRatiosDownloader() | ||
tickersym = 'nothing' | ||
exp = "MorningStar cannot find the ticker symbol you entered " \ | ||
"or it is INVALID. Please try again." | ||
with self.assertRaises(Exception) as context: | ||
checked = kr.download(tickersym) | ||
the_exception = context.exception | ||
return self.assertEqual(exp, str(the_exception), | ||
"Passing an invalid ticker symbol to" | ||
" good_morning fails") | ||
|
||
|
||
|
Oops, something went wrong.