Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalimaha committed Feb 9, 2016
1 parent c4717b4 commit 30af72b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fake_data_crud_service/core/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ def __init__(self, username, password, host, port, db):
self.client = MongoClient(self.uri)

def get(self, collection_name):
out = []
db = self.client[self.db]
collection = db[collection_name]
books = collection.find()
print books
items = collection.find()
for item in items:
out.append(item)
return out

def create_connection_uri(self):
return 'mongodb://' + self.username + ':' + self.password + '@' + self.host + ':' + self.port + '/' + self.db
10 changes: 10 additions & 0 deletions fake_data_crud_service_test/core/dao_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,13 @@ def test_create_connection_uri(self):
dao = DAO('kalimaha', 'Ce09114238', 'ds059145.mongolab.com', '59145', 'kalimadata')
uri = dao.create_connection_uri()
self.assertEqual(uri, 'mongodb://kalimaha:Ce09114238@ds059145.mongolab.com:59145/kalimadata')

def test_get(self):
dao = DAO('kalimaha', 'Ce09114238', 'ds059145.mongolab.com', '59145', 'kalimadata')
items = dao.get('books')
self.assertEqual(len(items), 1)
self.assertEqual(items[0]['ISBN'], '0-436-20305-7')
self.assertEqual(items[0]['author'], 'Howard Marks')
self.assertEqual(items[0]['genre'], 'non-fiction')
self.assertEqual(items[0]['title'], 'Mr. Nice')
self.assertEqual(items[0]['pages'], 466)
16 changes: 16 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from setuptools import setup
from setuptools import find_packages

setup(
name='FakeDataCRUDService',
version='0.1.0',
author='Guido Barbaglia',
author_email='guido.barbaglia@gmail.com',
packages=find_packages(),
license='LICENSE.txt',
description='Simple CRUD service for fake data.',
install_requires=[
'watchdog', 'flask', 'gunicorn', 'pymongo'
],
url='http://pypi.python.org/pypi/FakeDataCRUDService/'
)

0 comments on commit 30af72b

Please sign in to comment.