# Path: yithlibraryserver/db.py
# class MongoDB(object):
#     """Simple wrapper to get pymongo real objects from the settings uri"""
# 
#     def __init__(self, db_uri=DEFAULT_MONGODB_URI,
#                  connection_factory=pymongo.Connection):
#         self.db_uri = urlparse.urlparse(db_uri)
#         self.connection = connection_factory(
#             host=self.db_uri.hostname or DEFAULT_MONGODB_HOST,
#             port=self.db_uri.port or DEFAULT_MONGODB_PORT,
#             tz_aware=True)
# 
#         if self.db_uri.path:
#             self.database_name = self.db_uri.path[1:]
#         else:
#             self.database_name = DEFAULT_MONGODB_NAME
# 
#     def get_connection(self):
#         return self.connection
# 
#     def get_database(self):
#         database = self.connection[self.database_name]
#         if self.db_uri.username and self.db_uri.password:
#             database.authenticate(self.db_uri.username, self.db_uri.password)
# 
#         return database
# 
# Path: yithlibraryserver/sna_callbacks.py
# def facebook_callback(request, user_id, info):
#     return register_or_update(request, 'facebook', user_id, info,
#                               request.route_path('home'))
# 
# def google_callback(request, user_id, new_info):
#     return register_or_update(request, 'google', user_id, new_info,
#                               request.route_path('home'))
# 
# Path: yithlibraryserver/testing.py
# MONGO_URI = 'mongodb://localhost:27017/test-yith-library'


import unittest
from pyramid import testing
from yithlibraryserver.db import MongoDB
from yithlibraryserver.sna_callbacks import facebook_callback, google_callback
from yithlibraryserver.testing import MONGO_URI
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Yith Library Server is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Yith Library Server.  If not, see <http://www.gnu.org/licenses/>.





class SNACallbackTests(unittest.TestCase):

    def setUp(self):
        self.config = testing.setUp()
        self.config.include('yithlibraryserver')
        self.config.include('yithlibraryserver.user')
        self.request = testing.DummyRequest()
        self.request.session = {}
        mdb = MongoDB(MONGO_URI)
        self.request.db = mdb.get_database()

    def tearDown(self):
        testing.tearDown()

    def test_facebook_callback(self):

# Path: yithlibraryserver/db.py
# class MongoDB(object):
#     """Simple wrapper to get pymongo real objects from the settings uri"""
# 
#     def __init__(self, db_uri=DEFAULT_MONGODB_URI,
#                  connection_factory=pymongo.Connection):
#         self.db_uri = urlparse.urlparse(db_uri)
#         self.connection = connection_factory(
#             host=self.db_uri.hostname or DEFAULT_MONGODB_HOST,
#             port=self.db_uri.port or DEFAULT_MONGODB_PORT,
#             tz_aware=True)
# 
#         if self.db_uri.path:
#             self.database_name = self.db_uri.path[1:]
#         else:
#             self.database_name = DEFAULT_MONGODB_NAME
# 
#     def get_connection(self):
#         return self.connection
# 
#     def get_database(self):
#         database = self.connection[self.database_name]
#         if self.db_uri.username and self.db_uri.password:
#             database.authenticate(self.db_uri.username, self.db_uri.password)
# 
#         return database
# 
# Path: yithlibraryserver/sna_callbacks.py
# def facebook_callback(request, user_id, info):
#     return register_or_update(request, 'facebook', user_id, info,
#                               request.route_path('home'))
# 
# def google_callback(request, user_id, new_info):
#     return register_or_update(request, 'google', user_id, new_info,
#                               request.route_path('home'))
# 
# Path: yithlibraryserver/testing.py
# MONGO_URI = 'mongodb://localhost:27017/test-yith-library'


# Path: yithlibraryserver/tests/test_sna_callbacks.py
import unittest
from pyramid import testing
from yithlibraryserver.db import MongoDB
from yithlibraryserver.sna_callbacks import facebook_callback, google_callback
from yithlibraryserver.testing import MONGO_URI

# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Yith Library Server is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Yith Library Server.  If not, see <http://www.gnu.org/licenses/>.





class SNACallbackTests(unittest.TestCase):

    def setUp(self):
        self.config = testing.setUp()
        self.config.include('yithlibraryserver')
        self.config.include('yithlibraryserver.user')
        self.request = testing.DummyRequest()
        self.request.session = {}
        mdb = MongoDB(MONGO_URI)
        self.request.db = mdb.get_database()

    def tearDown(self):
        testing.tearDown()

    def test_facebook_callback(self):

        result = facebook_callback(self.request, '123', {