├── flask_analytics ├── providers │ ├── __init__.py │ ├── base.py │ ├── gosquared.py │ ├── gauges.py │ ├── googleuniversalanalytics.py │ ├── googleclassicanalytics.py │ ├── piwik.py │ └── chartbeat.py ├── __init__.py └── analytics.py ├── setup.cfg ├── test ├── templates │ └── index.html ├── app.py └── test_app.py ├── .gitignore ├── .travis.yml ├── Makefile ├── LICENSE ├── setup.py └── README.md /flask_analytics/providers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal=1 3 | -------------------------------------------------------------------------------- /test/templates/index.html: -------------------------------------------------------------------------------- 1 | {{analytics}} 2 | -------------------------------------------------------------------------------- /flask_analytics/__init__.py: -------------------------------------------------------------------------------- 1 | from flask_analytics.analytics import Analytics 2 | -------------------------------------------------------------------------------- /flask_analytics/providers/base.py: -------------------------------------------------------------------------------- 1 | class BaseProvider(object): 2 | 3 | pass 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.pyc 3 | *.egg-info 4 | .coverage 5 | cover/ 6 | build/ 7 | dist/ 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | 3 | python: 4 | - 2.7 5 | - 3.3 6 | - 3.4 7 | - 3.5 8 | 9 | install: 10 | - python setup.py install 11 | - pip install coveralls 12 | 13 | script: make test 14 | 15 | after_success: 16 | - coveralls 17 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | install: 2 | python setup.py install 3 | 4 | develop: 5 | python setup.py develop 6 | 7 | test: develop 8 | nosetests -v --with-coverage --cover-package=flask_analytics --cover-html 9 | 10 | publish: test 11 | python setup.py sdist bdist_wheel upload 12 | 13 | .PHONY: install develop publish 14 | -------------------------------------------------------------------------------- /flask_analytics/providers/gosquared.py: -------------------------------------------------------------------------------- 1 | from flask_analytics.providers.base import BaseProvider 2 | 3 | 4 | class GoSquared(BaseProvider): 5 | 6 | uid = None 7 | 8 | def __init__(self, uid=None): 9 | self.uid = uid 10 | 11 | @property 12 | def template(self): 13 | return """""" 21 | 22 | @property 23 | def source(self): 24 | if self.uid is None: 25 | return None 26 | return self.template.format(uid=self.uid) 27 | -------------------------------------------------------------------------------- /flask_analytics/providers/gauges.py: -------------------------------------------------------------------------------- 1 | from flask_analytics.providers.base import BaseProvider 2 | 3 | 4 | class Gauges(BaseProvider): 5 | 6 | site_id = None 7 | 8 | def __init__(self, site_id=None): 9 | self.site_id = site_id 10 | 11 | @property 12 | def template(self): 13 | return """""" 26 | 27 | @property 28 | def source(self): 29 | if self.site_id is None: 30 | return None 31 | return self.template.format(site_id=self.site_id) 32 | -------------------------------------------------------------------------------- /flask_analytics/providers/googleuniversalanalytics.py: -------------------------------------------------------------------------------- 1 | from flask_analytics.providers.base import BaseProvider 2 | 3 | 4 | class GoogleUniversalAnalytics(BaseProvider): 5 | 6 | account = None 7 | 8 | def __init__(self, account=None): 9 | self.account = account 10 | 11 | @property 12 | def template(self): 13 | return """""" 23 | 24 | @property 25 | def source(self): 26 | if self.account is None: 27 | return None 28 | return self.template.format(account=self.account) 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /flask_analytics/providers/googleclassicanalytics.py: -------------------------------------------------------------------------------- 1 | from flask_analytics.providers.base import BaseProvider 2 | 3 | 4 | class GoogleClassicAnalytics(BaseProvider): 5 | 6 | account = None 7 | 8 | def __init__(self, account=None): 9 | self.account = account 10 | 11 | @property 12 | def template(self): 13 | return """""" 26 | 27 | @property 28 | def source(self): 29 | if self.account is None: 30 | return None 31 | return self.template.format(account=self.account) 32 | -------------------------------------------------------------------------------- /flask_analytics/providers/piwik.py: -------------------------------------------------------------------------------- 1 | from flask_analytics.providers.base import BaseProvider 2 | 3 | 4 | class Piwik(BaseProvider): 5 | 6 | base_url = None 7 | site_id = None 8 | 9 | def __init__(self, base_url=None, site_id=None): 10 | self.base_url = base_url 11 | self.site_id = site_id 12 | 13 | @property 14 | def template(self): 15 | return """""" 27 | 28 | @property 29 | def source(self): 30 | if self.base_url is None or self.site_id is None: 31 | return None 32 | return self.template.format(base_url=self.base_url, 33 | site_id=self.site_id) 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | setup( 4 | name="Flask-Analytics", 5 | version="0.6.0", 6 | author="Mihir Singh (@citruspi)", 7 | author_email="hello@mihirsingh.com", 8 | description="Analytics snippets generator extension for the Flask framework", 9 | url='https://github.com/citruspi/Flask-Analytics', 10 | packages=['flask_analytics', 'flask_analytics.providers'], 11 | zip_safe=False, 12 | include_package_data=True, 13 | platforms='any', 14 | install_requires=[ 15 | 'Flask', 16 | ], 17 | classifiers=[ 18 | 'License :: Public Domain', 19 | 'Development Status :: 5 - Production/Stable', 20 | 'Environment :: Plugins', 21 | 'Framework :: Flask', 22 | 'Intended Audience :: Developers', 23 | 'Operating System :: MacOS :: MacOS X', 24 | 'Operating System :: Unix', 25 | 'Programming Language :: Python :: 2.7', 26 | 'Programming Language :: Python :: 3.0', 27 | 'Programming Language :: Python :: 3.1', 28 | 'Programming Language :: Python :: 3.2', 29 | 'Programming Language :: Python :: 3.3', 30 | 'Programming Language :: Python :: 3.4', 31 | 'Programming Language :: Python :: 3.5', 32 | 'Topic :: Internet' 33 | ] 34 | ) 35 | -------------------------------------------------------------------------------- /flask_analytics/providers/chartbeat.py: -------------------------------------------------------------------------------- 1 | from flask_analytics.providers.base import BaseProvider 2 | 3 | 4 | class Chartbeat(BaseProvider): 5 | 6 | uid = None 7 | domain = None 8 | 9 | def __init__(self, uid=None, domain=None): 10 | self.uid = uid 11 | self.domain = domain 12 | 13 | @property 14 | def template(self): 15 | return """""" 35 | 36 | @property 37 | def source(self): 38 | if self.uid is None or self.domain is None: 39 | return None 40 | return self.template.format(uid=self.uid, domain=self.domain) 41 | -------------------------------------------------------------------------------- /flask_analytics/analytics.py: -------------------------------------------------------------------------------- 1 | from flask import Markup 2 | from flask_analytics.providers.gosquared import GoSquared 3 | from flask_analytics.providers.chartbeat import Chartbeat 4 | from flask_analytics.providers.piwik import Piwik 5 | from flask_analytics.providers.gauges import Gauges 6 | from flask_analytics.providers.googleclassicanalytics import GoogleClassicAnalytics 7 | from flask_analytics.providers.googleuniversalanalytics import GoogleUniversalAnalytics 8 | 9 | 10 | class Analytics(object): 11 | 12 | provider_map = { 13 | 'gosquared': GoSquared, 14 | 'chartbeat': Chartbeat, 15 | 'piwik': Piwik, 16 | 'gauges': Gauges, 17 | 'google_classic_analytics': GoogleClassicAnalytics, 18 | 'google_universal_analytics': GoogleUniversalAnalytics 19 | } 20 | 21 | _source = '' 22 | _config = {} 23 | 24 | def __init__(self, app=None, disable_context_processor=False): 25 | self.app = app 26 | 27 | if app is not None: 28 | self.init_app(app, not(disable_context_processor)) 29 | 30 | def init_app(self, app, context_processor): 31 | self.build_source(app.config) 32 | 33 | if context_processor: 34 | app.context_processor(self._context_processor) 35 | 36 | @property 37 | def bootstrap(self): 38 | config = { 39 | 'ENABLED': True, 40 | } 41 | 42 | for provider in self.provider_map: 43 | subconfig = { 44 | 'ENABLED': True 45 | } 46 | 47 | args = self.provider_map[provider].__init__.__code__.co_varnames 48 | args = [arg for arg in args if arg != 'self'] 49 | 50 | for arg in args: 51 | subconfig[arg.upper()] = None 52 | 53 | config[provider.upper()] = subconfig 54 | 55 | return config 56 | 57 | def build_source(self, config): 58 | self._source = '' 59 | 60 | if 'ANALYTICS' not in config: 61 | self.app.config['ANALYTICS'] = self.bootstrap 62 | 63 | config = config['ANALYTICS'] 64 | 65 | enabled = config.get('ENABLED', True) 66 | 67 | if not enabled: 68 | return 69 | 70 | for provider in self.provider_map: 71 | if provider.upper() not in config: 72 | continue 73 | 74 | enabled = config[provider.upper()].get('ENABLED', True) 75 | 76 | if not enabled: 77 | continue 78 | 79 | args = config[provider.upper()] 80 | 81 | if 'ENABLED' in args: 82 | del args['ENABLED'] 83 | 84 | for key in list(args): 85 | args[key.lower()] = args.pop(key) 86 | 87 | instance = self.provider_map[provider](**args) 88 | 89 | if instance.source is not None: 90 | self._source += '\n' 91 | self._source += Markup(instance.source) 92 | 93 | self._source = self._source.lstrip() 94 | self._config = config 95 | 96 | @property 97 | def source(self): 98 | if self._config != self.app.config: 99 | self.build_source(self.app.config) 100 | 101 | return self._source 102 | 103 | def _context_processor(self): 104 | return dict(analytics=self.source) 105 | -------------------------------------------------------------------------------- /test/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template 2 | from flask_analytics import Analytics 3 | 4 | app = Flask(__name__) 5 | 6 | analytics = Analytics(app) 7 | 8 | 9 | @app.route('/') 10 | def index(): 11 | 12 | app.config['ANALYTICS'] = { 13 | 'GAUGES': { 14 | 'SITE_ID': 'soV5eile3aiFi9E' 15 | }, 16 | 'GOOGLE_CLASSIC_ANALYTICS': { 17 | 'ACCOUNT': 'wiengech9tiefuW', 18 | }, 19 | 'PIWIK': { 20 | 'BASE_URL': 'aeniki8pheiFiad', 21 | 'SITE_ID': 'uiP3eeKie6ohDo6', 22 | }, 23 | 'GOSQUARED': { 24 | 'UID': 'ahz1Nahqueorahw' 25 | }, 26 | 'CHARTBEAT': { 27 | 'UID': 'uiP3eeKie6ohDo6', 28 | 'DOMAIN': 'eeda8Otheefu5qu' 29 | }, 30 | 'GOOGLE_UNIVERSAL_ANALYTICS':{ 31 | 'ACCOUNT': 'iqmbak3kfpdg2N' 32 | } 33 | } 34 | 35 | return render_template('index.html') 36 | 37 | 38 | @app.route('/disabled/') 39 | def disabled(): 40 | 41 | app.config['ANALYTICS'] = { 42 | 'ENABLED': False, 43 | 'GAUGES': { 44 | 'SITE_ID': 'soV5eile3aiFi9E' 45 | }, 46 | 'GOOGLE_CLASSIC_ANALYTICS': { 47 | 'ACCOUNT': 'wiengech9tiefuW', 48 | }, 49 | 'PIWIK': { 50 | 'BASE_URL': 'aeniki8pheiFiad', 51 | 'SITE_ID': 'uiP3eeKie6ohDo6', 52 | }, 53 | 'GOSQUARED': { 54 | 'UID': 'ahz1Nahqueorahw' 55 | }, 56 | 'CHARTBEAT': { 57 | 'UID': 'uiP3eeKie6ohDo6', 58 | 'DOMAIN': 'eeda8Otheefu5qu' 59 | }, 60 | 'GOOGLE_UNIVERSAL_ANALYTICS':{ 61 | 'ACCOUNT': 'iqmbak3kfpdg2N' 62 | } 63 | } 64 | 65 | return render_template('index.html') 66 | 67 | 68 | @app.route('/none/') 69 | def none(): 70 | 71 | if 'ANALYTICS' in app.config: 72 | del app.config['ANALYTICS'] 73 | 74 | return render_template('index.html') 75 | 76 | 77 | @app.route('/google-classic/') 78 | def google(): 79 | 80 | app.config['ANALYTICS'] = { 81 | 'GOOGLE_CLASSIC_ANALYTICS': { 82 | 'ACCOUNT': 'wiengech9tiefuW', 83 | } 84 | } 85 | 86 | return render_template('index.html') 87 | 88 | 89 | @app.route('/gauges/') 90 | def gauges(): 91 | 92 | app.config['ANALYTICS'] = { 93 | 'GAUGES': { 94 | 'SITE_ID': 'soV5eile3aiFi9E' 95 | } 96 | } 97 | 98 | return render_template('index.html') 99 | 100 | 101 | @app.route('/piwik/') 102 | def piwik(): 103 | 104 | app.config['ANALYTICS'] = { 105 | 'PIWIK': { 106 | 'BASE_URL': 'aeniki8pheiFiad', 107 | 'SITE_ID': 'uiP3eeKie6ohDo6', 108 | } 109 | } 110 | 111 | return render_template('index.html') 112 | 113 | 114 | @app.route('/gosquared/') 115 | def gosquared(): 116 | 117 | app.config['ANALYTICS'] = { 118 | 'GOSQUARED': { 119 | 'UID': 'ahz1Nahqueorahw' 120 | } 121 | } 122 | 123 | return render_template('index.html') 124 | 125 | 126 | @app.route('/chartbeat/') 127 | def chartbeat(): 128 | 129 | app.config['ANALYTICS'] = { 130 | 'CHARTBEAT': { 131 | 'UID': 'uiP3eeKie6ohDo6', 132 | 'DOMAIN': 'eeda8Otheefu5qu' 133 | } 134 | } 135 | 136 | return render_template('index.html') 137 | 138 | @app.route('/google-universal/') 139 | def universal(): 140 | 141 | app.config['ANALYTICS'] = { 142 | 'GOOGLE_UNIVERSAL_ANALYTICS': { 143 | 'ACCOUNT': 'iqmbak3kfpdg2N', 144 | } 145 | } 146 | 147 | return render_template('index.html') 148 | 149 | if __name__ == '__main__': 150 | 151 | app.run() 152 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Travis branch](https://img.shields.io/travis/citruspi/Flask-Analytics/master.svg?style=flat-square)](https://travis-ci.org/citruspi/Flask-Analytics) 2 | [![Coveralls branch](https://img.shields.io/coveralls/citruspi/Flask-Analytics/master.svg?style=flat-square)](https://coveralls.io/github/citruspi/Flask-Analytics) 3 | [![License](https://img.shields.io/github/license/citruspi/Flask-Analytics.svg?style=flat-square)](http://unlicense.org) 4 | [![PyPI](https://img.shields.io/pypi/v/Flask-Analytics.svg?style=flat-square)](https://pypi.python.org/pypi/Flask-Analytics) 5 | [![PyPI](https://img.shields.io/pypi/wheel/Flask-Analytics.svg?style=flat-square)](https://pypi.python.org/pypi/Flask-Analytics) 6 | [![PyPI](https://img.shields.io/pypi/pyversions/Flask-Analytics.svg?style=flat-square)](https://pypi.python.org/pypi/Flask-Analytics) 7 | [![PyPI](https://img.shields.io/pypi/status/Flask-Analytics.svg?style=flat-square)](https://pypi.python.org/pypi/Flask-Analytics) 8 | 9 | ## Flask-Analytics 10 | 11 | Flask Analytics is an extension for Flask which generates analytics snippets for inclusion in templates. 12 | 13 | ## Installation 14 | 15 | ```bash 16 | $ pip install Flask-Analytics 17 | ``` 18 | 19 | ## Usage 20 | 21 | __app.py__ 22 | 23 | ```python 24 | from flask import Flask, render_template 25 | from flask_analytics import Analytics 26 | 27 | app = Flask(__name__) 28 | Analytics(app) 29 | 30 | app.config['ANALYTICS']['GAUGES']['SITE_ID'] = 'XXXXXXXXXXXXX' 31 | 32 | 33 | @app.route('/') 34 | def index(): 35 | 36 | return render_template('index.html') 37 | ``` 38 | 39 | __index.html__ 40 | 41 | ``` 42 | {{ analytics }} 43 | ``` 44 | 45 | __result__ 46 | 47 | ```html 48 | $ curl http://localhost:5000/ 49 | 62 | ``` 63 | 64 | ## Services 65 | 66 | `Flask-Analytics` uses keys defined in `app.config['ANALYTICS']` to determine which for which services analytics snippets should be generated. 67 | 68 | | Service | Keys Required | 69 | |:--------|:--------------| 70 | | [Google Analytics (ga.js)](http://www.google.com/analytics/) | `['GOOGLE_CLASSIC_ANALYTICS']['ACCOUNT']` | 71 | | [Universal Analytics (analytics.js) ](http://www.google.com/analytics/) | `['GOOGLE_UNIVERSAL_ANALYTICS']['ACCOUNT']` | 72 | | [Piwik](http://piwik.org/) | `['PIWIK']['BASE_URL']`
`['PIWIK']['SITE_ID']`| 73 | | [Gaug.es](http://gaug.es/) | `['GAUGES']['SITE_ID']` | 74 | | [Chartbeat](https://chartbeat.com) | `['CHARTBEAT']['UID']`
`['CHARTBEAT']['DOMAIN']` | 75 | | [GoSquared](https://www.gosquared.com) | `['GOSQUARED']['UID']` | 76 | 77 | Individual services can be disabled by setting the `ENABLED` key for that service (e.g. `['ANALYTICS']['PIWIK']['ENABLED']`). Analytics as a whole can be disabled by setting the `ENABLED` key at the top (e.g. `['ANALYTICS']['ENABLED']`). 78 | 79 | When a service, or analytics as a whole, is disabled, it returns an empty string, so it's safe to keep `{{analytics}}` in your template. 80 | 81 | When the configuration changes, the source for the analytics code will automatically be rebuilt the next time it's called. 82 | 83 | ## Tests 84 | 85 | ``` 86 | $ nosetests -v --with-coverage --cover-package=flask_analytics --cover-html 87 | test_all (test_app.TestAnalytics) ... ok 88 | test_boostrap (test_app.TestAnalytics) ... ok 89 | test_chartbeat (test_app.TestAnalytics) ... ok 90 | test_disabled (test_app.TestAnalytics) ... ok 91 | test_gauges (test_app.TestAnalytics) ... ok 92 | test_google_classic (test_app.TestAnalytics) ... ok 93 | test_google_universal (test_app.TestAnalytics) ... ok 94 | test_gosquared (test_app.TestAnalytics) ... ok 95 | test_none (test_app.TestAnalytics) ... ok 96 | test_piwik (test_app.TestAnalytics) ... ok 97 | 98 | Name Stmts Miss Cover Missing 99 | ------------------------------------------------------------------------------------- 100 | flask_analytics.py 1 0 100% 101 | flask_analytics/analytics.py 60 1 98% 77 102 | flask_analytics/providers.py 0 0 100% 103 | flask_analytics/providers/base.py 2 0 100% 104 | flask_analytics/providers/chartbeat.py 13 0 100% 105 | flask_analytics/providers/gauges.py 11 0 100% 106 | flask_analytics/providers/googleclassicanalytics.py 11 0 100% 107 | flask_analytics/providers/googleuniversalanalytics.py 11 0 100% 108 | flask_analytics/providers/gosquared.py 11 0 100% 109 | flask_analytics/providers/piwik.py 13 0 100% 110 | ------------------------------------------------------------------------------------- 111 | TOTAL 133 1 99% 112 | ---------------------------------------------------------------------- 113 | Ran 10 tests in 0.111s 114 | 115 | 116 | OK 117 | ``` 118 | 119 | ## License 120 | 121 | Flask-Analytics is dedicated to the public domain. Please read the license for 122 | more information. 123 | -------------------------------------------------------------------------------- /test/test_app.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import re 3 | from app import app, analytics 4 | 5 | class TestAnalytics(unittest.TestCase): 6 | 7 | def test_boostrap(self): 8 | 9 | expected = { 10 | 'CHARTBEAT': { 11 | 'DOMAIN': None, 12 | 'ENABLED': True, 13 | 'UID': None 14 | }, 15 | 'ENABLED': True, 16 | 'GAUGES': { 17 | 'ENABLED': True, 18 | 'SITE_ID': None 19 | }, 20 | 'GOOGLE_CLASSIC_ANALYTICS': { 21 | 'ACCOUNT': None, 22 | 'ENABLED': True 23 | }, 24 | 'GOOGLE_UNIVERSAL_ANALYTICS': { 25 | 'ACCOUNT': None, 26 | 'ENABLED': True 27 | }, 28 | 'GOSQUARED': { 29 | 'ENABLED': True, 30 | 'UID': None 31 | }, 32 | 'PIWIK': { 33 | 'BASE_URL': None, 34 | 'ENABLED': True, 35 | 'SITE_ID': None 36 | } 37 | } 38 | 39 | self.assertEquals(analytics.bootstrap, expected) 40 | 41 | def test_none(self): 42 | 43 | self.test_app = app.test_client() 44 | 45 | response = self.test_app.get('/none/') 46 | 47 | expected = "" 48 | 49 | self.assertEquals(response.data, expected.encode('utf8')) 50 | 51 | def test_disabled(self): 52 | 53 | self.test_app = app.test_client() 54 | 55 | response = self.test_app.get('/disabled/') 56 | 57 | expected = "" 58 | 59 | self.assertEquals(response.data, expected.encode('utf8')) 60 | 61 | 62 | def test_chartbeat(self): 63 | 64 | self.test_app = app.test_client() 65 | 66 | response = self.test_app.get('/chartbeat/') 67 | 68 | expected = """""" 88 | 89 | self.assertEquals(response.data, expected.encode('utf8')) 90 | 91 | def test_gosquared(self): 92 | 93 | self.test_app = app.test_client() 94 | 95 | response = self.test_app.get('/gosquared/') 96 | 97 | expected = """""" 105 | 106 | self.assertEquals(response.data, expected.encode('utf8')) 107 | 108 | def test_piwik(self): 109 | 110 | self.test_app = app.test_client() 111 | 112 | response = self.test_app.get('/piwik/') 113 | 114 | expected = """""" 126 | 127 | self.assertEquals(response.data, expected.encode('utf8')) 128 | 129 | def test_gauges(self): 130 | 131 | self.test_app = app.test_client() 132 | 133 | response = self.test_app.get('/gauges/') 134 | 135 | expected = """""" 148 | 149 | self.assertEquals(response.data, expected.encode('utf8')) 150 | 151 | def test_google_classic(self): 152 | 153 | self.test_app = app.test_client() 154 | 155 | response = self.test_app.get('/google-classic/') 156 | 157 | expected = """""" 170 | 171 | self.assertEquals(response.data, expected.encode('utf8')) 172 | 173 | def test_google_universal(self): 174 | 175 | self.test_app = app.test_client() 176 | 177 | response = self.test_app.get('/google-universal/') 178 | 179 | expected = """""" 189 | 190 | self.assertEquals(response.data, expected.encode('utf8')) 191 | 192 | 193 | def test_all(self): 194 | 195 | self.test_app = app.test_client() 196 | 197 | response = self.test_app.get('/') 198 | 199 | expected = """ 207 | 220 | 230 | 243 | 255 | """ 275 | 276 | 277 | 278 | response_sections = sorted(re.split('<|>',str(response.data))) 279 | expected_sections = sorted(re.split('<|>',str(expected.encode('utf')))) 280 | 281 | self.assertEquals(response_sections, expected_sections) 282 | --------------------------------------------------------------------------------