import unittest
from flask import Flask
from flask.ext.goat import Goat, OAUTH


class TestGoat(unittest.TestCase):

    def setUp(self):
        self.app = Flask(__name__)
        self.app.config.setdefault('GOAT_CLIENT_ID', 'publicid')
        self.app.config.setdefault('GOAT_CALLBACK', 'http://127.0.0.1:9000/callback')

    def test_smoke(self):
        with self.app.app_context():
            Goat(self.app)

    def test_state(self):
        with self.app.app_context():
            g = Goat(self.app)
            g.save_state('test')
            self.assertTrue(g.is_valid_state('test'))

    def test_make_auth_url(self):
        with self.app.app_context():
            g = Goat(self.app)
            go_to = 'https://example.com'
            url = g.make_auth_url(go_to)
            endpoint, params = url.split('?')
            self.assertEqual(endpoint, OAUTH + '/authorize')
            paramdict = dict([pair.split('=') for pair in params.split('&')])
            self.assertEqual(len(paramdict), 4)
            self.assertEqual(paramdict['client_id'], 'publicid')
            self.assertEqual(paramdict['scope'], 'read%3Aorg')

@@ -292,34 +292,23 @@
 http
+s
 ://
-127.0.0.1:9000/callback
+example.com
 ')%0A%0A
@@ -686,50 +686,8 @@
 pp)%0A
-            go_to = 'https://example.com'%0A
     
@@ -720,13 +720,8 @@
 url(
-go_to
 )%0A  

fix callback