# Path: gitmostwanted/blueprints/user_oauth.py
# @user_oauth.route('/oauth/login')
# def login():
#     return oauth.github.authorize_redirect(
#         redirect_uri=url_for('user_oauth.authorized', next=url_next(), _external=True),
#         scope=request.args.get('scope')
#     )
# 
# def url_next():
#     return request.args.get('next') or request.referrer or None
# 
# Path: gitmostwanted/web.py

# 
# Path: gitmostwanted/app.py



from gitmostwanted.blueprints.user_oauth import login, url_next
from gitmostwanted.web import app
from gitmostwanted.app import db
from unittest import TestCase, skipIf
import flask
    def setUp(self):
        self.app = app.test_client()

    def tearDown(self):
        pass

    @classmethod
    def setUpClass(cls):
        db.create_all()

    @classmethod
    def tearDownClass(cls):
        db.drop_all()

    def test_homepage(self):
        self.assertIn(
            '<title>The most interesting repositories (solid) - GitHub Explore</title>',
            self.app.get('/').data.decode('utf-8')
        )

    @skipIf('OAUTH_GITHUB' not in app.config, "Requires GitHub auth")
    def test_login_via_github(self):
        with app.test_request_context():
            resp = login()
            self.assertTrue(resp.headers['Location'].endswith('authorized'))
            self.assertEqual(resp.status_code, 302)

    def test_provide_correct_redirect_url(self):
        env_overrides = dict(HTTP_REFERER='http_referer')
        with app.test_request_context(environ_overrides=env_overrides):

# Path: gitmostwanted/blueprints/user_oauth.py
# @user_oauth.route('/oauth/login')
# def login():
#     return oauth.github.authorize_redirect(
#         redirect_uri=url_for('user_oauth.authorized', next=url_next(), _external=True),
#         scope=request.args.get('scope')
#     )
# 
# def url_next():
#     return request.args.get('next') or request.referrer or None
# 
# Path: gitmostwanted/web.py

# 
# Path: gitmostwanted/app.py



# Path: tests/unit/test_web.py
from gitmostwanted.blueprints.user_oauth import login, url_next
from gitmostwanted.web import app
from gitmostwanted.app import db
from unittest import TestCase, skipIf
import flask

    def setUp(self):
        self.app = app.test_client()

    def tearDown(self):
        pass

    @classmethod
    def setUpClass(cls):
        db.create_all()

    @classmethod
    def tearDownClass(cls):
        db.drop_all()

    def test_homepage(self):
        self.assertIn(
            '<title>The most interesting repositories (solid) - GitHub Explore</title>',
            self.app.get('/').data.decode('utf-8')
        )

    @skipIf('OAUTH_GITHUB' not in app.config, "Requires GitHub auth")
    def test_login_via_github(self):
        with app.test_request_context():
            resp = login()
            self.assertTrue(resp.headers['Location'].endswith('authorized'))
            self.assertEqual(resp.status_code, 302)

    def test_provide_correct_redirect_url(self):
        env_overrides = dict(HTTP_REFERER='http_referer')
        with app.test_request_context(environ_overrides=env_overrides):

            self.assertTrue(url_next().endswith('http_referer'))