Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed a few issues and added tests. bumped package to v0.2
- Loading branch information
Showing
6 changed files
with
113 additions
and
5 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
*.pyc | ||
tests/test_settings_local.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,12 @@ | ||
# Changelog | ||
|
||
## 0.2 - Tests & Fixes | ||
|
||
Added in the tests to ensure data is coming back for each api endpoint. Also added exception handling to URL open | ||
and to simplejson.load. API calls now convert the json-string to a python dictionary. | ||
|
||
Fixed a parameter/endpoint issue with connections | ||
|
||
## 0.1 - Initial Release | ||
|
||
Created first round of api endpoints and calls to get a string of json text |
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
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,85 @@ | ||
import unittest | ||
import logging | ||
import test_settings | ||
from eqentia_client.client import EqentiaRestClient | ||
|
||
''' | ||
Currently low level tests to ensure the API responds without Exception for each endpoint and that the | ||
response-key in data is set to True for valid response. | ||
In order to enable the test-harnass please define an api_token and portal in the test_settings | ||
''' | ||
|
||
class ClientTestCase(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.api_token = test_settings.api_token | ||
self.portal = test_settings.portal | ||
self.cl = EqentiaRestClient(api_token=self.api_token,portal=self.portal) | ||
|
||
def test_headine(self): | ||
print 'Running test_headline' | ||
headlines = self.cl.headlines() | ||
if headlines: | ||
self.assertTrue(headlines['response'], msg='A response was returned but the field response was False') | ||
else: | ||
self.assertTrue(headlines, msg='The API request failed due to an exception') | ||
|
||
def test_connections(self): | ||
print 'Running test_connections' | ||
connections = self.cl.connections(connection_id=50901) | ||
if connections: | ||
self.assertTrue(connections['response'], msg='A response was returned but the field response was False') | ||
else: | ||
self.assertTrue(connections, msg='The API request failed due to an exception') | ||
|
||
def test_connection_maps(self): | ||
print 'Running test_connection_maps' | ||
connection_maps = self.cl.connection_maps() | ||
if connection_maps: | ||
self.assertTrue(connection_maps['response'], msg='A response was returned but the field response was False') | ||
else: | ||
self.assertTrue(connection_maps, msg='The API request failed due to an exception') | ||
|
||
def test_curation(self): | ||
print 'Running test_curation' | ||
curation = self.cl.curation() | ||
if curation: | ||
self.assertTrue(curation['response'], msg='A response was returned but the field response was False') | ||
else: | ||
self.assertTrue(curation, msg='The API request failed due to an exception') | ||
|
||
def test_news_groups(self): | ||
print 'Running test_news_groups' | ||
news_groups = self.cl.news_groups() | ||
if news_groups: | ||
self.assertTrue(news_groups['response'], msg='A response was returned but the field response was False') | ||
else: | ||
self.assertTrue(news_groups, msg='The API request failed due to an exception') | ||
|
||
def test_navigation(self): | ||
print 'Running test_navigation' | ||
navigation = self.cl.navigation() | ||
if navigation: | ||
self.assertTrue(navigation['response'], msg='A response was returned but the field response was False') | ||
else: | ||
self.assertTrue(navigation, msg='The API request failed due to an exception') | ||
|
||
def test_hot_companies(self): | ||
print 'Running test_hot_companies' | ||
hot_companies = self.cl.hot_companies() | ||
if hot_companies: | ||
self.assertTrue(hot_companies['response'], msg='A response was returned but the field response was False') | ||
else: | ||
self.assertTrue(hot_companies, msg='The API request failed due to an exception') | ||
|
||
def test_hot_connections(self): | ||
print 'Running test_hot_connections' | ||
hot_connections = self.cl.hot_connections() | ||
if hot_connections: | ||
self.assertTrue(hot_connections['response'], msg='A response was returned but the field response was False') | ||
else: | ||
self.assertTrue(hot_connections, msg='The API request failed due to an exception') | ||
|
||
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,7 @@ | ||
# Import local settings if there are any | ||
# create your own local settings or put your api/portal here | ||
try: | ||
from test_settings_local import * | ||
except ImportError: | ||
api_token = 'api_token_here' | ||
portal = 'portal_here' |