Skip to content

Commit

Permalink
Merge branch 'master' into collabs
Browse files Browse the repository at this point in the history
  • Loading branch information
aayush26 committed Oct 29, 2017
2 parents adbfee0 + 9c5971c commit 58a9163
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -6,3 +6,5 @@
.eggs/
*.egg-info/
.coverage
.idea/
venv/
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -10,6 +10,7 @@ python:
- "pypy-5.3.1"

install:
- pip install -U setuptools
- pip install -e .
- pip install -r requirements-dev.txt

Expand Down
1 change: 1 addition & 0 deletions pirant/__init__.py
@@ -1 +1,2 @@
from __future__ import absolute_import, division, print_function
from .app import DevRant
6 changes: 4 additions & 2 deletions pirant/app.py
@@ -1,7 +1,9 @@
from __future__ import absolute_import, division, print_function
from builtins import object
from .handlers import RequestHandler, ResponseHandler


class DevRant:
class DevRant(object):

def __init__(self):
self.RequestHandler = RequestHandler()
Expand Down Expand Up @@ -29,4 +31,4 @@ def get_collabs(self, skip, limit):

def get_collab_by_id(self, collab_id):
response = self.RequestHandler.get_rant_by_id(collab_id)
return self.ResponseHandler.get_rant_by_id_build_response(response)
return self.ResponseHandler.get_rant_by_id_build_response(response)
10 changes: 6 additions & 4 deletions pirant/handlers.py
@@ -1,10 +1,12 @@
from __future__ import absolute_import, division, print_function
import json
import requests
from builtins import object
from .models import RantsResponse, RantResponse, SearchResponse
from .urlbuilder import URLBuilder


class ResponseHandler:
class ResponseHandler(object):

def __init__(self):
self.RantsResponse = RantsResponse()
Expand All @@ -31,7 +33,7 @@ def get_collabs_build_response(self, response):
deserialized = self.RantsResponse.deserialize(json_string)
return deserialized

class RequestHandler:
class RequestHandler(object):

def __init__(self):
self.UrlBuilder = URLBuilder()
Expand All @@ -55,8 +57,8 @@ def search_rants_by_keyword(self, keyword):
url = self.UrlBuilder.search_rants_by_keywords(keyword)
response = requests.get(url)
return response

def get_collabs(self, skip, sort):
url = self.UrlBuilder.get_collabs_url(skip, sort)
response = requests.get(url)
return response
return response
3 changes: 2 additions & 1 deletion pirant/models.py
@@ -1,3 +1,4 @@
from __future__ import absolute_import, division, print_function
import colander

class News(colander.MappingSchema):
Expand Down Expand Up @@ -88,4 +89,4 @@ class RantResponse(colander.MappingSchema):
class SearchResponse(colander.MappingSchema):
success = colander.SchemaNode(colander.Boolean(), missing=colander.drop)
error = colander.SchemaNode(colander.Boolean(), missing=colander.drop)
results = Rants()
results = Rants()
6 changes: 5 additions & 1 deletion pirant/urlbuilder.py
@@ -1,4 +1,8 @@
class URLBuilder:
from __future__ import absolute_import, division, print_function
from builtins import str
from builtins import object

class URLBuilder(object):
def __init__(self):
self.APP_VERSION = 3
self.BASE_URL = "https://www.devrant.io/api/devrant"
Expand Down
7 changes: 5 additions & 2 deletions pirant/utils.py
@@ -1,8 +1,11 @@
class MockHttpResponse:
from __future__ import absolute_import, division, print_function
from builtins import object

class MockHttpResponse(object):
"""
Test Util: mocks response
"""
# TODO Move this to helpers under tests directory
def __init__(self, content, status_code):
self.content = content
self.status_code = status_code
self.status_code = status_code
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -18,6 +18,7 @@
install_requires=[
"colander",
"requests",
"future",
],
setup_requires=[
"pytest-runner"
Expand Down
1 change: 1 addition & 0 deletions tests/test_app.py
@@ -1,3 +1,4 @@
from __future__ import absolute_import, division, print_function
import unittest
from pirant import DevRant
from mock import patch
Expand Down
3 changes: 2 additions & 1 deletion tests/test_handlers.py
@@ -1,3 +1,4 @@
from __future__ import absolute_import, division, print_function
import unittest
from mock import Mock, patch
from pirant.handlers import RequestHandler, ResponseHandler
Expand Down Expand Up @@ -188,4 +189,4 @@ def test_successful_search_rants_by_keyword_build_response(self):
mockResponse = MockHttpResponse(test_content, test_status_code)
searchResults = self.responseHandler.search_rants_by_keyword_build_response(mockResponse)
assert searchResults['results'][0]['id'] == 173
assert searchResults['success'] == True
assert searchResults['success'] == True
1 change: 1 addition & 0 deletions tests/test_model.py
@@ -1,3 +1,4 @@
from __future__ import absolute_import, division, print_function
import unittest
import colander
import pirant.models
Expand Down
1 change: 1 addition & 0 deletions tests/test_urlbuilder.py
@@ -1,3 +1,4 @@
from __future__ import absolute_import, division, print_function
import unittest

from pirant.urlbuilder import URLBuilder
Expand Down
1 change: 1 addition & 0 deletions tests/test_utils.py
@@ -1,3 +1,4 @@
from __future__ import absolute_import, division, print_function
import unittest
from pirant.utils import MockHttpResponse

Expand Down

0 comments on commit 58a9163

Please sign in to comment.