mirror of
https://github.com/jazzband/django-analytical.git
synced 2026-03-16 22:20:25 +00:00
Implemented isort
This commit is contained in:
parent
f0e7ebe731
commit
37009f2e08
60 changed files with 184 additions and 169 deletions
|
|
@ -3,14 +3,13 @@ Analytical template tags and filters.
|
|||
"""
|
||||
|
||||
import logging
|
||||
from importlib import import_module
|
||||
|
||||
from django import template
|
||||
from django.template import Node, TemplateSyntaxError
|
||||
from importlib import import_module
|
||||
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
|
||||
TAG_LOCATIONS = ['head_top', 'head_bottom', 'body_top', 'body_bottom']
|
||||
TAG_POSITIONS = ['first', None, 'last']
|
||||
TAG_MODULES = [
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@ from django.conf import settings
|
|||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.template import Library, Node, TemplateSyntaxError
|
||||
|
||||
from analytical.utils import is_internal_ip, disable_html, get_required_setting
|
||||
|
||||
from analytical.utils import disable_html, get_required_setting, is_internal_ip
|
||||
|
||||
USER_ID_RE = re.compile(r'^\d+$')
|
||||
INIT_CODE = """<script type="text/javascript">var _sf_startpt=(new Date()).getTime()</script>"""
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ import re
|
|||
|
||||
from django.template import Library, Node, TemplateSyntaxError
|
||||
|
||||
from analytical.utils import is_internal_ip, disable_html, get_required_setting
|
||||
|
||||
from analytical.utils import disable_html, get_required_setting, is_internal_ip
|
||||
|
||||
CLICKMAP_TRACKER_ID_RE = re.compile(r'^\w+$')
|
||||
TRACKING_CODE = """
|
||||
|
|
|
|||
|
|
@ -7,9 +7,12 @@ import re
|
|||
|
||||
from django.template import Library, Node, TemplateSyntaxError
|
||||
|
||||
from analytical.utils import get_identity, is_internal_ip, disable_html, \
|
||||
get_required_setting
|
||||
|
||||
from analytical.utils import (
|
||||
disable_html,
|
||||
get_identity,
|
||||
get_required_setting,
|
||||
is_internal_ip,
|
||||
)
|
||||
|
||||
SITE_ID_RE = re.compile(r'^\d+$')
|
||||
TRACKING_CODE = """
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ import re
|
|||
|
||||
from django.template import Library, Node, TemplateSyntaxError
|
||||
|
||||
from analytical.utils import is_internal_ip, disable_html, get_required_setting
|
||||
|
||||
from analytical.utils import disable_html, get_required_setting, is_internal_ip
|
||||
|
||||
ACCOUNT_NUMBER_RE = re.compile(r'^\d+$')
|
||||
SETUP_CODE = '<script type="text/javascript" src="{placeholder_url}">' \
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ import re
|
|||
|
||||
from django.template import Library, Node, TemplateSyntaxError
|
||||
|
||||
from analytical.utils import get_required_setting, is_internal_ip, disable_html
|
||||
|
||||
from analytical.utils import disable_html, get_required_setting, is_internal_ip
|
||||
|
||||
FACEBOOK_PIXEL_HEAD_CODE = """\
|
||||
<script>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import re
|
|||
|
||||
from django.template import Library, Node, TemplateSyntaxError
|
||||
|
||||
from analytical.utils import is_internal_ip, disable_html, get_required_setting
|
||||
from analytical.utils import disable_html, get_required_setting, is_internal_ip
|
||||
|
||||
SITE_ID_RE = re.compile(r'[\da-f]+$')
|
||||
TRACKING_CODE = """
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ Google Analytics template tags and filters, using the new analytics.js library.
|
|||
|
||||
import decimal
|
||||
import re
|
||||
|
||||
from django.conf import settings
|
||||
from django.template import Library, Node, TemplateSyntaxError
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,12 @@ import re
|
|||
|
||||
from django.template import Library, Node, TemplateSyntaxError
|
||||
|
||||
from analytical.utils import get_identity, \
|
||||
is_internal_ip, disable_html, get_required_setting
|
||||
|
||||
from analytical.utils import (
|
||||
disable_html,
|
||||
get_identity,
|
||||
get_required_setting,
|
||||
is_internal_ip,
|
||||
)
|
||||
|
||||
TOKEN_RE = re.compile(r'^\S+-\S+-\S+$')
|
||||
TRACKING_CODE = """
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ import re
|
|||
|
||||
from django.template import Library, Node, TemplateSyntaxError
|
||||
|
||||
from analytical.utils import get_required_setting, is_internal_ip, disable_html
|
||||
|
||||
from analytical.utils import disable_html, get_required_setting, is_internal_ip
|
||||
|
||||
HOTJAR_TRACKING_CODE = """\
|
||||
<script>
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ import re
|
|||
|
||||
from django.template import Library, Node, TemplateSyntaxError
|
||||
|
||||
from analytical.utils import is_internal_ip, disable_html, get_required_setting
|
||||
|
||||
from analytical.utils import disable_html, get_required_setting, is_internal_ip
|
||||
|
||||
PORTAL_ID_RE = re.compile(r'^\d+$')
|
||||
TRACKING_CODE = """
|
||||
|
|
|
|||
|
|
@ -10,9 +10,14 @@ import re
|
|||
from django.conf import settings
|
||||
from django.template import Library, Node, TemplateSyntaxError
|
||||
|
||||
from analytical.utils import disable_html, get_required_setting, \
|
||||
is_internal_ip, get_user_from_context, get_identity, \
|
||||
get_user_is_authenticated
|
||||
from analytical.utils import (
|
||||
disable_html,
|
||||
get_identity,
|
||||
get_required_setting,
|
||||
get_user_from_context,
|
||||
get_user_is_authenticated,
|
||||
is_internal_ip,
|
||||
)
|
||||
|
||||
APP_ID_RE = re.compile(r'[\da-z]+$')
|
||||
TRACKING_CODE = """
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ from django.template import Library, Node, TemplateSyntaxError
|
|||
|
||||
from analytical.utils import get_identity, get_required_setting
|
||||
|
||||
|
||||
ACCOUNT_NUMBER_RE = re.compile(r'^\d+$')
|
||||
SITE_CODE_RE = re.compile(r'^[\w]+$')
|
||||
SETUP_CODE = """
|
||||
|
|
|
|||
|
|
@ -7,9 +7,12 @@ import re
|
|||
|
||||
from django.template import Library, Node, TemplateSyntaxError
|
||||
|
||||
from analytical.utils import is_internal_ip, disable_html, get_identity, \
|
||||
get_required_setting
|
||||
|
||||
from analytical.utils import (
|
||||
disable_html,
|
||||
get_identity,
|
||||
get_required_setting,
|
||||
is_internal_ip,
|
||||
)
|
||||
|
||||
API_KEY_RE = re.compile(r'^[0-9a-f]{40}$')
|
||||
TRACKING_CODE = """
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ import re
|
|||
|
||||
from django.template import Library, Node, TemplateSyntaxError
|
||||
|
||||
from analytical.utils import get_required_setting, is_internal_ip, disable_html
|
||||
|
||||
from analytical.utils import disable_html, get_required_setting, is_internal_ip
|
||||
|
||||
LUCKYORANGE_TRACKING_CODE = """\
|
||||
<script type='text/javascript'>
|
||||
|
|
|
|||
|
|
@ -2,16 +2,19 @@
|
|||
Matomo template tags and filters.
|
||||
"""
|
||||
|
||||
import re
|
||||
from collections import namedtuple
|
||||
from itertools import chain
|
||||
import re
|
||||
|
||||
from django.conf import settings
|
||||
from django.template import Library, Node, TemplateSyntaxError
|
||||
|
||||
from analytical.utils import (is_internal_ip, disable_html,
|
||||
get_required_setting, get_identity)
|
||||
|
||||
from analytical.utils import (
|
||||
disable_html,
|
||||
get_identity,
|
||||
get_required_setting,
|
||||
is_internal_ip,
|
||||
)
|
||||
|
||||
# domain name (characters separated by a dot), optional port, optional URI path, no slash
|
||||
DOMAINPATH_RE = re.compile(r'^(([^./?#@:]+\.)*[^./?#@:]+)+(:[0-9]+)?(/[^/?#@:]+)*$')
|
||||
|
|
|
|||
|
|
@ -8,9 +8,12 @@ import re
|
|||
from django.template import Library, Node, TemplateSyntaxError
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from analytical.utils import is_internal_ip, disable_html, get_identity, \
|
||||
get_required_setting
|
||||
|
||||
from analytical.utils import (
|
||||
disable_html,
|
||||
get_identity,
|
||||
get_required_setting,
|
||||
is_internal_ip,
|
||||
)
|
||||
|
||||
MIXPANEL_API_TOKEN_RE = re.compile(r'^[0-9a-f]{32}$')
|
||||
TRACKING_CODE = """
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ from django.template import Library, Node, TemplateSyntaxError
|
|||
|
||||
from analytical.utils import get_identity, get_required_setting
|
||||
|
||||
|
||||
SITE_ID_RE = re.compile(r'^\d+-\d+-\d+-\d+$')
|
||||
SETUP_CODE = """
|
||||
<script type='text/javascript'>
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ import re
|
|||
|
||||
from django.template import Library, Node, TemplateSyntaxError
|
||||
|
||||
from analytical.utils import is_internal_ip, disable_html, get_required_setting
|
||||
|
||||
from analytical.utils import disable_html, get_required_setting, is_internal_ip
|
||||
|
||||
ACCOUNT_NUMBER_RE = re.compile(r'^\d+$')
|
||||
SETUP_CODE = """<script src="//cdn.optimizely.com/js/%(account_number)s.js"></script>"""
|
||||
|
|
|
|||
|
|
@ -7,9 +7,12 @@ import re
|
|||
from django.template import Library, Node, TemplateSyntaxError
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from analytical.utils import is_internal_ip, disable_html, get_identity, \
|
||||
get_required_setting
|
||||
|
||||
from analytical.utils import (
|
||||
disable_html,
|
||||
get_identity,
|
||||
get_required_setting,
|
||||
is_internal_ip,
|
||||
)
|
||||
|
||||
API_KEY_RE = re.compile(r'^\w+$')
|
||||
SETUP_CODE = """
|
||||
|
|
|
|||
|
|
@ -2,17 +2,20 @@
|
|||
Piwik template tags and filters.
|
||||
"""
|
||||
|
||||
import re
|
||||
import warnings
|
||||
from collections import namedtuple
|
||||
from itertools import chain
|
||||
import re
|
||||
|
||||
from django.conf import settings
|
||||
from django.template import Library, Node, TemplateSyntaxError
|
||||
|
||||
from analytical.utils import (is_internal_ip, disable_html,
|
||||
get_required_setting, get_identity)
|
||||
|
||||
import warnings
|
||||
from analytical.utils import (
|
||||
disable_html,
|
||||
get_identity,
|
||||
get_required_setting,
|
||||
is_internal_ip,
|
||||
)
|
||||
|
||||
# domain name (characters separated by a dot), optional port, optional URI path, no slash
|
||||
DOMAINPATH_RE = re.compile(r'^(([^./?#@:]+\.)*[^./?#@:]+)+(:[0-9]+)?(/[^/?#@:]+)*$')
|
||||
|
|
|
|||
|
|
@ -6,9 +6,7 @@ import re
|
|||
|
||||
from django.template import Library, Node, TemplateSyntaxError
|
||||
|
||||
from analytical.utils import is_internal_ip, disable_html, \
|
||||
get_required_setting
|
||||
|
||||
from analytical.utils import disable_html, get_required_setting, is_internal_ip
|
||||
|
||||
COUNTER_ID_RE = re.compile(r'^\d{7}$')
|
||||
COUNTER_CODE = """
|
||||
|
|
|
|||
|
|
@ -6,9 +6,12 @@ import re
|
|||
|
||||
from django.template import Library, Node, TemplateSyntaxError
|
||||
|
||||
from analytical.utils import get_identity, is_internal_ip, disable_html, \
|
||||
get_required_setting
|
||||
|
||||
from analytical.utils import (
|
||||
disable_html,
|
||||
get_identity,
|
||||
get_required_setting,
|
||||
is_internal_ip,
|
||||
)
|
||||
|
||||
TRACKING_ID_RE = re.compile(r'^[0-9a-f]+$')
|
||||
TRACKING_CODE = """
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ import re
|
|||
|
||||
from django.conf import settings
|
||||
from django.template import Library, Node, TemplateSyntaxError
|
||||
from analytical.utils import get_required_setting, get_identity
|
||||
|
||||
from analytical.utils import get_identity, get_required_setting
|
||||
|
||||
WIDGET_KEY_RE = re.compile(r'^[a-zA-Z0-9]*$')
|
||||
TRACKING_CODE = """
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@ import re
|
|||
from django.conf import settings
|
||||
from django.template import Library, Node, TemplateSyntaxError
|
||||
|
||||
from analytical.utils import is_internal_ip, disable_html, \
|
||||
get_required_setting
|
||||
|
||||
from analytical.utils import disable_html, get_required_setting, is_internal_ip
|
||||
|
||||
COUNTER_ID_RE = re.compile(r'^\d{8}$')
|
||||
COUNTER_CODE = """
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ Utility function for django-analytical.
|
|||
from django.conf import settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
|
||||
HTML_COMMENT = "<!-- %(service)s disabled on internal IP " \
|
||||
"address\n%(html)s\n-->"
|
||||
|
||||
|
|
|
|||
|
|
@ -8,3 +8,6 @@ upload-dir = build/docs/html
|
|||
|
||||
[tool:pytest]
|
||||
DJANGO_SETTINGS_MODULE = tests.testproject.settings
|
||||
|
||||
[isort]
|
||||
profile = black
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ from django.template import Library, Node, TemplateSyntaxError
|
|||
|
||||
from analytical.templatetags.analytical import TAG_LOCATIONS
|
||||
|
||||
|
||||
register = Library()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ Tests for the generic template tags and filters.
|
|||
"""
|
||||
|
||||
from django.template import Context, Template
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags import analytical
|
||||
from utils import TagTestCase
|
||||
|
||||
|
||||
class AnalyticsTagTestCase(TagTestCase):
|
||||
|
|
|
|||
|
|
@ -4,17 +4,15 @@ Tests for the Chartbeat template tags and filters.
|
|||
|
||||
import re
|
||||
|
||||
import pytest
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from analytical.templatetags.chartbeat import ChartbeatTopNode, \
|
||||
ChartbeatBottomNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
from analytical.templatetags.chartbeat import ChartbeatBottomNode, ChartbeatTopNode
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
|
||||
@override_settings(CHARTBEAT_USER_ID='12345')
|
||||
|
|
|
|||
|
|
@ -2,16 +2,15 @@
|
|||
Tests for the Clickmap template tags and filters.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.clickmap import ClickmapNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@override_settings(CLICKMAP_TRACKER_ID='12345ABC')
|
||||
class ClickmapTagTestCase(TagTestCase):
|
||||
|
|
|
|||
|
|
@ -4,17 +4,16 @@ Tests for the Clicky template tags and filters.
|
|||
|
||||
import re
|
||||
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
import pytest
|
||||
from django.contrib.auth.models import AnonymousUser, User
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.clicky import ClickyNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@override_settings(CLICKY_SITE_ID='12345678')
|
||||
class ClickyTagTestCase(TagTestCase):
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
Tests for the Crazy Egg template tags and filters.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
import pytest
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.crazy_egg import CrazyEggNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,19 @@
|
|||
"""
|
||||
Tests for the Facebook Pixel template tags.
|
||||
"""
|
||||
import pytest
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context, Template, TemplateSyntaxError
|
||||
from django.test import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.analytical import _load_template_nodes
|
||||
from analytical.templatetags.facebook_pixel import FacebookPixelHeadNode, FacebookPixelBodyNode
|
||||
from utils import TagTestCase
|
||||
from analytical.templatetags.facebook_pixel import (
|
||||
FacebookPixelBodyNode,
|
||||
FacebookPixelHeadNode,
|
||||
)
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
expected_head_html = """\
|
||||
<script>
|
||||
!function(f,b,e,v,n,t,s)
|
||||
|
|
|
|||
|
|
@ -2,16 +2,15 @@
|
|||
Tests for the Gauges template tags and filters.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.gauges import GaugesNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@override_settings(GAUGES_SITE_ID='1234567890abcdef0123456789')
|
||||
class GaugesTagTestCase(TagTestCase):
|
||||
|
|
|
|||
|
|
@ -2,18 +2,23 @@
|
|||
Tests for the Google Analytics template tags and filters.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TagTestCase, TestCase
|
||||
|
||||
from analytical.templatetags.google_analytics import GoogleAnalyticsNode, \
|
||||
TRACK_SINGLE_DOMAIN, TRACK_MULTIPLE_DOMAINS, TRACK_MULTIPLE_SUBDOMAINS,\
|
||||
SCOPE_VISITOR, SCOPE_SESSION, SCOPE_PAGE
|
||||
from utils import TestCase, TagTestCase
|
||||
from analytical.templatetags.google_analytics import (
|
||||
SCOPE_PAGE,
|
||||
SCOPE_SESSION,
|
||||
SCOPE_VISITOR,
|
||||
TRACK_MULTIPLE_DOMAINS,
|
||||
TRACK_MULTIPLE_SUBDOMAINS,
|
||||
TRACK_SINGLE_DOMAIN,
|
||||
GoogleAnalyticsNode,
|
||||
)
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@override_settings(GOOGLE_ANALYTICS_PROPERTY_ID='UA-123456-7',
|
||||
GOOGLE_ANALYTICS_TRACKING_STYLE=TRACK_SINGLE_DOMAIN)
|
||||
|
|
|
|||
|
|
@ -2,17 +2,16 @@
|
|||
Tests for the Google Analytics template tags and filters, using the new gtag.js library.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from django.contrib.auth.models import User
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.google_analytics_gtag import GoogleAnalyticsGTagNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@override_settings(GOOGLE_ANALYTICS_GTAG_PROPERTY_ID='UA-123456-7')
|
||||
class GoogleAnalyticsTagTestCase(TagTestCase):
|
||||
|
|
|
|||
|
|
@ -2,17 +2,20 @@
|
|||
Tests for the Google Analytics template tags and filters, using the new analytics.js library.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TagTestCase, TestCase
|
||||
|
||||
from analytical.templatetags.google_analytics_js import GoogleAnalyticsJsNode, \
|
||||
TRACK_SINGLE_DOMAIN, TRACK_MULTIPLE_DOMAINS, TRACK_MULTIPLE_SUBDOMAINS
|
||||
from utils import TestCase, TagTestCase
|
||||
from analytical.templatetags.google_analytics_js import (
|
||||
TRACK_MULTIPLE_DOMAINS,
|
||||
TRACK_MULTIPLE_SUBDOMAINS,
|
||||
TRACK_SINGLE_DOMAIN,
|
||||
GoogleAnalyticsJsNode,
|
||||
)
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@override_settings(GOOGLE_ANALYTICS_JS_PROPERTY_ID='UA-123456-7',
|
||||
GOOGLE_ANALYTICS_TRACKING_STYLE=TRACK_SINGLE_DOMAIN)
|
||||
|
|
|
|||
|
|
@ -2,17 +2,16 @@
|
|||
Tests for the GoSquared template tags and filters.
|
||||
"""
|
||||
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
import pytest
|
||||
from django.contrib.auth.models import AnonymousUser, User
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.gosquared import GoSquaredNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@override_settings(GOSQUARED_SITE_TOKEN='ABC-123456-D')
|
||||
class GoSquaredTagTestCase(TagTestCase):
|
||||
|
|
|
|||
|
|
@ -1,17 +1,16 @@
|
|||
"""
|
||||
Tests for the Hotjar template tags.
|
||||
"""
|
||||
import pytest
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context, Template, TemplateSyntaxError
|
||||
from django.test import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.analytical import _load_template_nodes
|
||||
from analytical.templatetags.hotjar import HotjarNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
expected_html = """\
|
||||
<script>
|
||||
(function(h,o,t,j,a,r){
|
||||
|
|
|
|||
|
|
@ -2,16 +2,15 @@
|
|||
Tests for the HubSpot template tags and filters.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.hubspot import HubSpotNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@override_settings(HUBSPOT_PORTAL_ID='1234')
|
||||
class HubSpotTagTestCase(TagTestCase):
|
||||
|
|
|
|||
|
|
@ -4,17 +4,16 @@ Tests for the intercom template tags and filters.
|
|||
|
||||
import datetime
|
||||
|
||||
import pytest
|
||||
from django.contrib.auth.models import User
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.intercom import IntercomNode, intercom_user_hash
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@override_settings(INTERCOM_APP_ID="abc123xyz")
|
||||
class IntercomTagTestCase(TagTestCase):
|
||||
|
|
|
|||
|
|
@ -2,16 +2,15 @@
|
|||
Tests for the KISSinsights template tags and filters.
|
||||
"""
|
||||
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
import pytest
|
||||
from django.contrib.auth.models import AnonymousUser, User
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.kiss_insights import KissInsightsNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@override_settings(KISS_INSIGHTS_ACCOUNT_NUMBER='12345', KISS_INSIGHTS_SITE_CODE='abc')
|
||||
class KissInsightsTagTestCase(TagTestCase):
|
||||
|
|
|
|||
|
|
@ -2,17 +2,16 @@
|
|||
Tests for the KISSmetrics tags and filters.
|
||||
"""
|
||||
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
import pytest
|
||||
from django.contrib.auth.models import AnonymousUser, User
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.kiss_metrics import KissMetricsNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@override_settings(KISS_METRICS_API_KEY='0123456789abcdef0123456789abcdef01234567')
|
||||
class KissMetricsTagTestCase(TagTestCase):
|
||||
|
|
|
|||
|
|
@ -1,17 +1,16 @@
|
|||
"""
|
||||
Tests for the Lucky Orange template tags.
|
||||
"""
|
||||
import pytest
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context, Template, TemplateSyntaxError
|
||||
from django.test import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.analytical import _load_template_nodes
|
||||
from analytical.templatetags.luckyorange import LuckyOrangeNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
expected_html = """\
|
||||
<script type='text/javascript'>
|
||||
window.__lo_site_id = 123456;
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@
|
|||
Tests for the Matomo template tags and filters.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from django.contrib.auth.models import User
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
import pytest
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.matomo import MatomoNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,17 +2,16 @@
|
|||
Tests for the Mixpanel tags and filters.
|
||||
"""
|
||||
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
import pytest
|
||||
from django.contrib.auth.models import AnonymousUser, User
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.mixpanel import MixpanelNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@override_settings(MIXPANEL_API_TOKEN='0123456789abcdef0123456789abcdef')
|
||||
class MixpanelTagTestCase(TagTestCase):
|
||||
|
|
|
|||
|
|
@ -2,16 +2,15 @@
|
|||
Tests for the Olark template tags and filters.
|
||||
"""
|
||||
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
import pytest
|
||||
from django.contrib.auth.models import AnonymousUser, User
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.olark import OlarkNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@override_settings(OLARK_SITE_ID='1234-567-89-0123')
|
||||
class OlarkTestCase(TagTestCase):
|
||||
|
|
|
|||
|
|
@ -2,16 +2,15 @@
|
|||
Tests for the Optimizely template tags and filters.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.optimizely import OptimizelyNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@override_settings(OPTIMIZELY_ACCOUNT_NUMBER='1234567')
|
||||
class OptimizelyTagTestCase(TagTestCase):
|
||||
|
|
|
|||
|
|
@ -2,17 +2,16 @@
|
|||
Tests for the Performable template tags and filters.
|
||||
"""
|
||||
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
import pytest
|
||||
from django.contrib.auth.models import AnonymousUser, User
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.performable import PerformableNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@override_settings(PERFORMABLE_API_KEY='123ABC')
|
||||
class PerformableTagTestCase(TagTestCase):
|
||||
|
|
|
|||
|
|
@ -2,17 +2,16 @@
|
|||
Tests for the Piwik template tags and filters.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from django.contrib.auth.models import User
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.piwik import PiwikNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@override_settings(PIWIK_DOMAIN_PATH='example.com', PIWIK_SITE_ID='345')
|
||||
class PiwikTagTestCase(TagTestCase):
|
||||
|
|
|
|||
|
|
@ -2,16 +2,15 @@
|
|||
Tests for the Rating@Mail.ru template tags and filters.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.rating_mailru import RatingMailruNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@override_settings(RATING_MAILRU_COUNTER_ID='1234567')
|
||||
class RatingMailruTagTestCase(TagTestCase):
|
||||
|
|
|
|||
|
|
@ -2,19 +2,25 @@
|
|||
Tests for the SnapEngage template tags and filters.
|
||||
"""
|
||||
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
import pytest
|
||||
from django.contrib.auth.models import AnonymousUser, User
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from django.utils import translation
|
||||
|
||||
from analytical.templatetags.snapengage import SnapEngageNode, \
|
||||
BUTTON_STYLE_LIVE, BUTTON_STYLE_DEFAULT, BUTTON_STYLE_NONE, \
|
||||
BUTTON_LOCATION_LEFT, BUTTON_LOCATION_RIGHT, BUTTON_LOCATION_TOP, \
|
||||
BUTTON_LOCATION_BOTTOM, FORM_POSITION_TOP_LEFT
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
from analytical.templatetags.snapengage import (
|
||||
BUTTON_LOCATION_BOTTOM,
|
||||
BUTTON_LOCATION_LEFT,
|
||||
BUTTON_LOCATION_RIGHT,
|
||||
BUTTON_LOCATION_TOP,
|
||||
BUTTON_STYLE_DEFAULT,
|
||||
BUTTON_STYLE_LIVE,
|
||||
BUTTON_STYLE_NONE,
|
||||
FORM_POSITION_TOP_LEFT,
|
||||
SnapEngageNode,
|
||||
)
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
WIDGET_ID = 'ec329c69-0bf0-4db8-9b77-3f8150fb977e'
|
||||
|
||||
|
|
|
|||
|
|
@ -2,17 +2,16 @@
|
|||
Tests for the Spring Metrics template tags and filters.
|
||||
"""
|
||||
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
import pytest
|
||||
from django.contrib.auth.models import AnonymousUser, User
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.spring_metrics import SpringMetricsNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@override_settings(SPRING_METRICS_TRACKING_ID='12345678')
|
||||
class SpringMetricsTagTestCase(TagTestCase):
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
Tests for the UserVoice tags and filters.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
import pytest
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.uservoice import UserVoiceNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,17 +2,16 @@
|
|||
Tests for the Woopra template tags and filters.
|
||||
"""
|
||||
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
import pytest
|
||||
from django.contrib.auth.models import AnonymousUser, User
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.woopra import WoopraNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@override_settings(WOOPRA_DOMAIN='example.com')
|
||||
class WoopraTagTestCase(TagTestCase):
|
||||
|
|
|
|||
|
|
@ -3,16 +3,15 @@ Tests for the Yandex.Metrica template tags and filters.
|
|||
"""
|
||||
|
||||
|
||||
import pytest
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TagTestCase
|
||||
|
||||
from analytical.templatetags.yandex_metrica import YandexMetricaNode
|
||||
from utils import TagTestCase
|
||||
from analytical.utils import AnalyticalException
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@override_settings(YANDEX_METRICA_COUNTER_ID='12345678')
|
||||
class YandexMetricaTagTestCase(TagTestCase):
|
||||
|
|
|
|||
|
|
@ -3,11 +3,13 @@ Tests for the analytical.utils module.
|
|||
"""
|
||||
# import django
|
||||
|
||||
import pytest
|
||||
from django.contrib.auth.models import AbstractBaseUser
|
||||
from django.db import models
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
from django.test.utils import override_settings
|
||||
from utils import TestCase
|
||||
|
||||
from analytical.utils import (
|
||||
AnalyticalException,
|
||||
|
|
@ -16,9 +18,6 @@ from analytical.utils import (
|
|||
get_required_setting,
|
||||
is_internal_ip,
|
||||
)
|
||||
from utils import TestCase
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
class SettingDeletedTestCase(TestCase):
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Testing utilities.
|
||||
"""
|
||||
|
||||
from django.template import Template, Context, RequestContext
|
||||
from django.template import Context, RequestContext, Template
|
||||
from django.test.testcases import TestCase
|
||||
|
||||
|
||||
|
|
|
|||
8
tox.ini
8
tox.ini
|
|
@ -2,7 +2,7 @@
|
|||
envlist =
|
||||
# Python/Django combinations that are officially supported
|
||||
py{36,37,38,39}-django{22,30,31}
|
||||
py37-{flake8,bandit,readme,docs}
|
||||
py37-{flake8,bandit,readme,docs,isort}
|
||||
|
||||
[testenv]
|
||||
description = Unit tests
|
||||
|
|
@ -41,6 +41,12 @@ description = Static code analysis and code style
|
|||
deps = flake8
|
||||
commands = flake8
|
||||
|
||||
[testenv:py37-isort]
|
||||
description = Ensure imports are ordered
|
||||
skip_install = True
|
||||
deps = isort
|
||||
commands = isort tests setup.py analytical --check --diff
|
||||
|
||||
[testenv:py37-readme]
|
||||
description = Ensure README renders on PyPI
|
||||
deps = twine
|
||||
|
|
|
|||
Loading…
Reference in a new issue