django-cms-qe 3.5.0__py3-none-any.whl → 3.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cms_qe/api/constants.py +1 -0
- cms_qe/api/permissions.py +12 -0
- cms_qe/api/urls.py +32 -0
- cms_qe/api/utils.py +14 -0
- cms_qe/api/views.py +20 -0
- cms_qe/locale/cs/LC_MESSAGES/django.po +12 -0
- cms_qe/migrations/0001_api_permissions.py +19 -0
- cms_qe/settings/base/app.py +9 -0
- cms_qe/templates/admin/index.html +38 -0
- cms_qe/urls.py +1 -0
- cms_qe_auth/utils.py +6 -2
- {django_cms_qe-3.5.0.dist-info → django_cms_qe-3.6.0.dist-info}/METADATA +29 -11
- {django_cms_qe-3.5.0.dist-info → django_cms_qe-3.6.0.dist-info}/RECORD +18 -45
- {django_cms_qe-3.5.0.dist-info → django_cms_qe-3.6.0.dist-info}/WHEEL +1 -1
- cms_qe/static/css/fix-admin.css +0 -14
- cms_qe/templates/admin/change_form.html +0 -7
- cms_qe/tests/test_errors.py +0 -61
- cms_qe/tests/test_export.py +0 -108
- cms_qe/tests/test_monitoring.py +0 -15
- cms_qe/tests/test_utils.py +0 -77
- cms_qe/tests/test_views_security.py +0 -18
- cms_qe_analytical/tests/settings.py +0 -24
- cms_qe_analytical/tests/templatetags/__init__.py +0 -0
- cms_qe_analytical/tests/templatetags/dummy.py +0 -37
- cms_qe_analytical/tests/test_tag_google_analytics.py +0 -178
- cms_qe_analytical/tests/test_tag_piwik.py +0 -152
- cms_qe_analytical/tests/test_utils.py +0 -112
- cms_qe_analytical/tests/utils.py +0 -56
- cms_qe_auth/tests/__init__.py +0 -0
- cms_qe_auth/tests/test_models.py +0 -70
- cms_qe_auth/tests/test_utils.py +0 -36
- cms_qe_auth/tests/test_view.py +0 -72
- cms_qe_auth/tests/utils.py +0 -22
- cms_qe_newsletter/tests/__init__.py +0 -0
- cms_qe_newsletter/tests/test_mailchimp.py +0 -38
- cms_qe_newsletter/tests/test_managment.py +0 -22
- cms_qe_newsletter/tests/test_models.py +0 -43
- cms_qe_newsletter/tests/test_plugin.py +0 -21
- cms_qe_newsletter/tests/test_sync.py +0 -71
- cms_qe_newsletter/tests/test_views.py +0 -13
- cms_qe_table/tests/__init__.py +0 -0
- cms_qe_table/tests/test_models.py +0 -23
- cms_qe_table/tests/test_plugin.py +0 -18
- cms_qe_table/tests/test_utils.py +0 -90
- cms_qe_video/tests/__init__.py +0 -0
- cms_qe_video/tests/test_models.py +0 -96
- cms_qe_video/tests/test_plugin.py +0 -24
- cms_qe_video/tests/test_templatetags.py +0 -20
- /cms_qe/{tests → api}/__init__.py +0 -0
- {cms_qe_analytical/tests → cms_qe/migrations}/__init__.py +0 -0
- {django_cms_qe-3.5.0.dist-info → django_cms_qe-3.6.0.dist-info/licenses}/LICENSE +0 -0
- {django_cms_qe-3.5.0.dist-info → django_cms_qe-3.6.0.dist-info}/top_level.txt +0 -0
cms_qe_auth/tests/test_models.py
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import re
|
|
2
|
-
|
|
3
|
-
from django.test import override_settings
|
|
4
|
-
from django.urls.converters import SlugConverter
|
|
5
|
-
from pytest_data import use_data
|
|
6
|
-
|
|
7
|
-
from cms_qe_auth.models import User
|
|
8
|
-
from cms_qe_auth.tests.utils import reset_urls
|
|
9
|
-
from cms_qe_auth.utils import pk_to_uidb64
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def test_set_username_by_email():
|
|
13
|
-
user = User(email='user@example.com')
|
|
14
|
-
assert not user.username
|
|
15
|
-
user.save()
|
|
16
|
-
assert user.username == user.email
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
@use_data(user_data={'username': 'user@example.com', 'email': 'user@example.com'})
|
|
20
|
-
def test_set_username_by_changing_email(user):
|
|
21
|
-
assert user.username == 'user@example.com'
|
|
22
|
-
user.email = 'another@example.com'
|
|
23
|
-
assert user.username == 'user@example.com'
|
|
24
|
-
user.save()
|
|
25
|
-
assert user.username == 'another@example.com'
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
@use_data(user_data={'email': 'user@example.com'})
|
|
29
|
-
def test_unset_is_active_by_changing_email(user):
|
|
30
|
-
assert user.is_active
|
|
31
|
-
user.email = 'another@example.com'
|
|
32
|
-
assert user.is_active
|
|
33
|
-
user.save()
|
|
34
|
-
assert not user.is_active
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def test_simple_token_generation_and_checking(user):
|
|
38
|
-
token = user._generate_activation_token()
|
|
39
|
-
assert user._check_activation_token(token)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
@use_data(user_data={'is_active': False})
|
|
43
|
-
def test_simple_token_generation_and_activate_is_active(user):
|
|
44
|
-
assert not user.is_active
|
|
45
|
-
token = user._generate_activation_token()
|
|
46
|
-
user.activate(token)
|
|
47
|
-
assert user.is_active
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
@use_data(user_data={'is_active': False})
|
|
51
|
-
def test_simple_token_generation_and_activate_invalid(user):
|
|
52
|
-
user._generate_activation_token()
|
|
53
|
-
assert not user.activate("123456789ABZ-987654321abcdefg")
|
|
54
|
-
assert not user.is_active
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
@override_settings(CMS_QE_AUTH_ENABLED=True)
|
|
58
|
-
def test_activation_email_sending(mailoutbox):
|
|
59
|
-
reset_urls()
|
|
60
|
-
user = User(username='testuser', email='testuser@example.com', is_active=False)
|
|
61
|
-
user.save(base_url="http://example.com")
|
|
62
|
-
assert len(mailoutbox) == 1
|
|
63
|
-
email = mailoutbox[0]
|
|
64
|
-
assert user.email == email.to[0]
|
|
65
|
-
assert 'activate' in email.subject.lower()
|
|
66
|
-
token_re = f'(?P<token>{SlugConverter.regex})'
|
|
67
|
-
url_re = fr'//example.com/en/auth/activate/{pk_to_uidb64(user.pk)}/{token_re}'
|
|
68
|
-
match = re.findall(url_re, email.body)
|
|
69
|
-
assert match
|
|
70
|
-
assert user._check_activation_token(match[0])
|
cms_qe_auth/tests/test_utils.py
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
from pytest_data import use_data
|
|
3
|
-
|
|
4
|
-
from ..utils import get_user_by_uidb64, pk_to_uidb64, uidb64_to_pk
|
|
5
|
-
|
|
6
|
-
UIDB64_TEST_DATA = (
|
|
7
|
-
'pk, uid',
|
|
8
|
-
[
|
|
9
|
-
('1', 'MQ'),
|
|
10
|
-
('99', 'OTk'),
|
|
11
|
-
('100', 'MTAw'),
|
|
12
|
-
('123456', 'MTIzNDU2')
|
|
13
|
-
]
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
@pytest.mark.parametrize(*UIDB64_TEST_DATA)
|
|
18
|
-
def test_uidb64_to_pk(pk, uid):
|
|
19
|
-
assert uidb64_to_pk(uid) == pk
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
@pytest.mark.parametrize(*UIDB64_TEST_DATA)
|
|
23
|
-
def test_pk_to_uidb64(pk, uid):
|
|
24
|
-
assert pk_to_uidb64(pk) == uid
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
@use_data(user_data={'id': 1})
|
|
28
|
-
def test_get_user_by_uidb64(user):
|
|
29
|
-
assert user.pk == 1
|
|
30
|
-
assert user == get_user_by_uidb64("MQ")
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
@use_data(user_data={'id': 1})
|
|
34
|
-
def test_get_user_by_uidb64_user_not_exits(user):
|
|
35
|
-
user = get_user_by_uidb64("Mg")
|
|
36
|
-
assert not user
|
cms_qe_auth/tests/test_view.py
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import re
|
|
2
|
-
|
|
3
|
-
from django.contrib.auth import get_user_model
|
|
4
|
-
from django.test import override_settings
|
|
5
|
-
from pytest_data import use_data
|
|
6
|
-
|
|
7
|
-
from cms_qe_auth.tests.utils import reset_urls
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@override_settings(CMS_QE_AUTH_ENABLED=True)
|
|
11
|
-
@use_data(user_data={'username': 'testuser', 'password': 'testpass'})
|
|
12
|
-
def test_login(client, user):
|
|
13
|
-
reset_urls()
|
|
14
|
-
res = client.post('/en/auth/login/', {'username': 'testuser', 'password': 'testpass'})
|
|
15
|
-
assert res.status_code == 302
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
@override_settings(CMS_QE_AUTH_ENABLED=True)
|
|
19
|
-
def test_register(mailoutbox, client):
|
|
20
|
-
assert len(mailoutbox) == 0
|
|
21
|
-
assert not get_user_model().objects.filter(username='testuser')
|
|
22
|
-
|
|
23
|
-
reset_urls()
|
|
24
|
-
user = _register_user(client)
|
|
25
|
-
|
|
26
|
-
assert user.email == 'testuser@example.com'
|
|
27
|
-
assert len(mailoutbox) == 1
|
|
28
|
-
activation_mail = mailoutbox[0]
|
|
29
|
-
assert 'activate' in activation_mail.body
|
|
30
|
-
assert 'http' in activation_mail.body
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
@override_settings(AUTHENTICATION_BACKENDS=[
|
|
34
|
-
'django.contrib.auth.backends.ModelBackend',
|
|
35
|
-
'cms_qe_auth.tests.utils.TestAuthBackend',
|
|
36
|
-
], CMS_QE_AUTH_ENABLED=True)
|
|
37
|
-
def test_activation_multiple_authentication_backends(client, mailoutbox):
|
|
38
|
-
_test_activation(client, mailoutbox)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
@override_settings(CMS_QE_AUTH_ENABLED=True)
|
|
42
|
-
def test_activation(client, mailoutbox):
|
|
43
|
-
_test_activation(client, mailoutbox)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def _test_activation(client, mailoutbox):
|
|
47
|
-
reset_urls()
|
|
48
|
-
user = get_user_model()(username='testuser', email='testuser@example.com', is_active=False)
|
|
49
|
-
user.save(base_url="http://example.com")
|
|
50
|
-
|
|
51
|
-
# Get activation link from email
|
|
52
|
-
activation_mail = mailoutbox[0]
|
|
53
|
-
activate_url_pattern = r'(?P<url>https?://[^\s]+/activate/[^\s]+)'
|
|
54
|
-
url = re.search(activate_url_pattern, activation_mail.body).group('url')
|
|
55
|
-
|
|
56
|
-
response = client.get(url)
|
|
57
|
-
user.refresh_from_db()
|
|
58
|
-
|
|
59
|
-
assert user.is_active
|
|
60
|
-
# Test automatic login
|
|
61
|
-
assert response.context['user'].is_authenticated
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def _register_user(client):
|
|
65
|
-
res = client.post('/en/auth/register/', {
|
|
66
|
-
'username': 'testuser',
|
|
67
|
-
'password1': '179ad45c6ce2cb97cf1029e212046e81',
|
|
68
|
-
'password2': '179ad45c6ce2cb97cf1029e212046e81',
|
|
69
|
-
'email': 'testuser@example.com',
|
|
70
|
-
})
|
|
71
|
-
assert res.status_code == 302
|
|
72
|
-
return get_user_model().objects.get(username='testuser')
|
cms_qe_auth/tests/utils.py
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
|
|
3
|
-
from django.conf import settings
|
|
4
|
-
from django.contrib.auth import get_user_model
|
|
5
|
-
from django.contrib.auth.backends import ModelBackend
|
|
6
|
-
from django.urls import clear_url_caches
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class TestAuthBackend(ModelBackend):
|
|
10
|
-
def authenticate(self, username=None, password=None):
|
|
11
|
-
User = get_user_model()
|
|
12
|
-
try:
|
|
13
|
-
user = User.objects.get(username=username)
|
|
14
|
-
return user
|
|
15
|
-
except User.DoesNotExist:
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def reset_urls():
|
|
20
|
-
"""Reset Django site urls."""
|
|
21
|
-
del sys.modules[settings.ROOT_URLCONF]
|
|
22
|
-
clear_url_caches()
|
|
File without changes
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
from constance.test import override_config
|
|
3
|
-
from django.conf import settings
|
|
4
|
-
from mailchimp3.mailchimpclient import MailChimpError
|
|
5
|
-
from pytest_data import use_data
|
|
6
|
-
|
|
7
|
-
from ..external_services.mailchimp import sync_mailing_lists, sync_subscribe, sync_unsubscribe
|
|
8
|
-
from ..models import MailingList
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
@override_config(
|
|
12
|
-
MAILCHIMP_USERNAME=settings.TEST_MAILCHIMP_USERNAME,
|
|
13
|
-
MAILCHIMP_API_KEY=settings.TEST_MAILCHIMP_API_KEY,
|
|
14
|
-
)
|
|
15
|
-
def test_sync_mailing_lists_integrate():
|
|
16
|
-
with pytest.raises(MailChimpError) as exc_info:
|
|
17
|
-
_test_sync_mailing_lists()
|
|
18
|
-
assert exc_info.value.args[0]['title'] == 'API Key Invalid'
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def test_sync_mailing_lists(mock_mailchimp):
|
|
22
|
-
_test_sync_mailing_lists()
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def _test_sync_mailing_lists():
|
|
26
|
-
assert MailingList.objects.count() == 0
|
|
27
|
-
sync_mailing_lists()
|
|
28
|
-
assert MailingList.objects.count() == 2
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
@use_data(cms_qe_mailchimp_subscribe_data={'id': 'subid'})
|
|
32
|
-
def test_sync_subscribe(mock_mailchimp):
|
|
33
|
-
assert 'subid' == sync_subscribe('listid', 'test@example.com', 'first', 'last')
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def test_sync_unsubscribe(mock_mailchimp):
|
|
37
|
-
# No exception.
|
|
38
|
-
sync_unsubscribe('listid', 'test@example.com')
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
from unittest import mock
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def test_not_set_mailchimp():
|
|
5
|
-
with mock.patch('cms_qe_newsletter.external_services.sync.sync_tasks', return_value=[
|
|
6
|
-
(True, 'ok'),
|
|
7
|
-
(None, 'warning'),
|
|
8
|
-
(False, 'error'),
|
|
9
|
-
]):
|
|
10
|
-
# Import here so mock works correctly.
|
|
11
|
-
from ..management.commands.cms_qe_newsletter_sync import Command
|
|
12
|
-
|
|
13
|
-
with mock.patch('cms_qe_newsletter.management.commands.cms_qe_newsletter_sync.logger') as log_mock:
|
|
14
|
-
command = Command()
|
|
15
|
-
command.handle()
|
|
16
|
-
assert log_mock.info.call_args_list == [
|
|
17
|
-
mock.call('Newsletter sync started...'),
|
|
18
|
-
mock.call('ok'),
|
|
19
|
-
mock.call('Newsletter sync finished...'),
|
|
20
|
-
]
|
|
21
|
-
assert log_mock.warning.call_args_list == [mock.call('warning')]
|
|
22
|
-
assert log_mock.error.call_args_list == [mock.call('error')]
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
from django.core.exceptions import ValidationError
|
|
3
|
-
from pytest_data import use_data
|
|
4
|
-
|
|
5
|
-
from ..models import SERVICE_MAILCHIMP, Subscriber, SubscribeTask
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def test_clean_newsletter_plugin(cms_qe_newsletter_plugin):
|
|
9
|
-
cms_qe_newsletter_plugin.fullname_show = False
|
|
10
|
-
cms_qe_newsletter_plugin.fullname_require = True
|
|
11
|
-
with pytest.raises(ValidationError):
|
|
12
|
-
cms_qe_newsletter_plugin.clean()
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def test_validate_mailing_list(cms_qe_mailing_list):
|
|
16
|
-
cms_qe_mailing_list.external_service = SERVICE_MAILCHIMP
|
|
17
|
-
cms_qe_mailing_list.external_id = None
|
|
18
|
-
with pytest.raises(ValidationError):
|
|
19
|
-
cms_qe_mailing_list.clean()
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def test_save_will_create_task(cms_qe_mailing_list):
|
|
23
|
-
sub = Subscriber(
|
|
24
|
-
mailing_list=cms_qe_mailing_list,
|
|
25
|
-
email='test@example.com',
|
|
26
|
-
)
|
|
27
|
-
assert SubscribeTask.objects.all().count() == 0
|
|
28
|
-
sub.save()
|
|
29
|
-
assert SubscribeTask.objects.all().count() == 1
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
@use_data(cms_qe_subscriber_data={'external_id': 'test_id'})
|
|
33
|
-
def test_delete_will_create_task(cms_qe_subscriber):
|
|
34
|
-
assert SubscribeTask.objects.all().count() == 0
|
|
35
|
-
cms_qe_subscriber.delete()
|
|
36
|
-
assert SubscribeTask.objects.all().count() == 1
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
@use_data(cms_qe_subscriber_data={'external_id': None})
|
|
40
|
-
def test_delete_will_remove_pending_task(cms_qe_subscriber):
|
|
41
|
-
assert SubscribeTask.objects.all().count() == 1
|
|
42
|
-
cms_qe_subscriber.delete()
|
|
43
|
-
assert SubscribeTask.objects.all().count() == 0
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
from cms_qe_test import render_plugin
|
|
2
|
-
|
|
3
|
-
from ..cms_plugins import NewsletterPlugin
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def test_render():
|
|
7
|
-
html = render_plugin(NewsletterPlugin)
|
|
8
|
-
assert '<form' in html
|
|
9
|
-
assert '<input' in html
|
|
10
|
-
assert 'email' in html
|
|
11
|
-
assert 'first' not in html
|
|
12
|
-
assert 'last' not in html
|
|
13
|
-
assert 'submit' in html
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def test_render_fullname_show():
|
|
17
|
-
html = render_plugin(NewsletterPlugin, fullname_show=True)
|
|
18
|
-
assert 'email' in html
|
|
19
|
-
assert 'first' in html
|
|
20
|
-
assert 'last' in html
|
|
21
|
-
assert 'submit' in html
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
from pytest_data import use_data
|
|
2
|
-
|
|
3
|
-
from ..external_services.sync import sync_task, sync_tasks
|
|
4
|
-
from ..models import SubscribeTask
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@use_data(
|
|
8
|
-
cms_qe_mailing_list_data={'external_service': 99},
|
|
9
|
-
cms_qe_subscribe_task_data={
|
|
10
|
-
'attempts': 0,
|
|
11
|
-
'last_error': 0,
|
|
12
|
-
},
|
|
13
|
-
)
|
|
14
|
-
def test_save_failure(cms_qe_subscribe_task):
|
|
15
|
-
assert SubscribeTask.objects.all().count() == 1
|
|
16
|
-
result, message = list(sync_tasks())[0]
|
|
17
|
-
assert 'Unsupported service 99' in message
|
|
18
|
-
assert result is False
|
|
19
|
-
cms_qe_subscribe_task.refresh_from_db()
|
|
20
|
-
assert cms_qe_subscribe_task.attempts == 1
|
|
21
|
-
assert cms_qe_subscribe_task.last_error == 'Unsupported service 99'
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
@use_data(cms_qe_subscribe_task_data={'attempts': 10})
|
|
25
|
-
def test_warning_do_not_increment_failure(cms_qe_subscribe_task):
|
|
26
|
-
assert SubscribeTask.objects.all().count() == 1
|
|
27
|
-
result, message = list(sync_tasks())[0]
|
|
28
|
-
assert 'Skipped' in message
|
|
29
|
-
assert result is None
|
|
30
|
-
cms_qe_subscribe_task.refresh_from_db()
|
|
31
|
-
assert cms_qe_subscribe_task.attempts == 10
|
|
32
|
-
assert cms_qe_subscribe_task.last_error == ''
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
@use_data(cms_qe_subscribe_task_data={'attempts': 10})
|
|
36
|
-
def test_task_skip(cms_qe_subscribe_task):
|
|
37
|
-
result, message = sync_task(cms_qe_subscribe_task)
|
|
38
|
-
assert 'Skipped' in message
|
|
39
|
-
assert result is None
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
@use_data(
|
|
43
|
-
cms_qe_mailing_list_data={'external_service': 99},
|
|
44
|
-
cms_qe_subscribe_task_data={
|
|
45
|
-
'attempts': 0,
|
|
46
|
-
'last_error': 0,
|
|
47
|
-
},
|
|
48
|
-
)
|
|
49
|
-
def test_task_unsupported_service(cms_qe_subscribe_task):
|
|
50
|
-
result, message = sync_task(cms_qe_subscribe_task)
|
|
51
|
-
assert 'Unsupported service 99' in message
|
|
52
|
-
assert result is False
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
@use_data(
|
|
56
|
-
cms_qe_subscribe_task_data={'email': '-no-subscriber-@example.com'},
|
|
57
|
-
)
|
|
58
|
-
def test_task_with_removed_subscriber(cms_qe_subscribe_task):
|
|
59
|
-
result, message = sync_task(cms_qe_subscribe_task)
|
|
60
|
-
assert 'Subscriber does not exist anymore, deleting task' in message
|
|
61
|
-
assert result is None
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
@use_data(
|
|
65
|
-
cms_qe_subscriber_data={'email': 'test@example.com'},
|
|
66
|
-
cms_qe_subscribe_task_data={'email': 'test@example.com'},
|
|
67
|
-
)
|
|
68
|
-
def test_task_synced(cms_qe_subscribe_task, cms_qe_subscriber, mock_mailchimp):
|
|
69
|
-
result, message = sync_task(cms_qe_subscribe_task)
|
|
70
|
-
assert 'OK' in message
|
|
71
|
-
assert result is True
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
from ..models import MailingList
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def test_get_lists_from_mailchimp(mock_mailchimp, admin_client):
|
|
5
|
-
assert MailingList.objects.count() == 0
|
|
6
|
-
admin_client.get('/cms-qe/newsletter/sync-lists')
|
|
7
|
-
assert MailingList.objects.count() == 2
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def test_get_lists_from_mailchimp_not_staff(mock_mailchimp, client):
|
|
11
|
-
assert MailingList.objects.count() == 0
|
|
12
|
-
client.get('/cms-qe/newsletter/sync-lists')
|
|
13
|
-
assert MailingList.objects.count() == 0
|
cms_qe_table/tests/__init__.py
DELETED
|
File without changes
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
from django.core.paginator import Page
|
|
2
|
-
from pytest_data import use_data
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def test_get_header(cms_qe_table_model):
|
|
6
|
-
assert cms_qe_table_model.get_header() == ['username', 'password']
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
@use_data(cms_qe_table_model_data={'paging_show': False})
|
|
10
|
-
def test_get_items_without_paging(cms_qe_table_model):
|
|
11
|
-
assert cms_qe_table_model.get_items() == []
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@use_data(cms_qe_table_model_data={'paging_show': True})
|
|
15
|
-
def test_get_items_with_paging(cms_qe_table_model):
|
|
16
|
-
items = cms_qe_table_model.get_items()
|
|
17
|
-
assert isinstance(items, Page)
|
|
18
|
-
assert list(items) == []
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
@use_data(cms_qe_table_model_data={'columns': ['does_not_exist']})
|
|
22
|
-
def test_columns_exist(cms_qe_table_model):
|
|
23
|
-
assert not cms_qe_table_model.columns_exist
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
from cms_qe_test import render_plugin
|
|
2
|
-
|
|
3
|
-
from ..cms_plugins import TablePlugin
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def test_render():
|
|
7
|
-
html = render_plugin(TablePlugin, table='auth_user')
|
|
8
|
-
assert '<table>' in html
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def test_render_not_existing_table():
|
|
12
|
-
html = render_plugin(TablePlugin, table='table_does_not_exist')
|
|
13
|
-
assert 'Table table_does_not_exist does not exist!' in html
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def test_render_table_with_not_existing_column():
|
|
17
|
-
html = render_plugin(TablePlugin, table='auth_user', columns=['column_does_not_exist'])
|
|
18
|
-
assert 'Some column does not exist!' in html
|
cms_qe_table/tests/test_utils.py
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
from django.contrib.auth import get_user_model
|
|
3
|
-
from django.db import models
|
|
4
|
-
from django.db.models import Q
|
|
5
|
-
|
|
6
|
-
from ..exceptions import TableDoesNotExists
|
|
7
|
-
from ..utils import get_field_type, get_filter_params, get_model_by_table, get_models_choices, get_table_choices
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def test_get_model_by_table():
|
|
11
|
-
User = get_user_model()
|
|
12
|
-
model = get_model_by_table('auth_user')
|
|
13
|
-
assert model is User
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def test_get_model_by_table_not_found():
|
|
17
|
-
with pytest.raises(TableDoesNotExists):
|
|
18
|
-
get_model_by_table('table_does_not_exist')
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def test_get_all_models():
|
|
22
|
-
choices = get_models_choices()
|
|
23
|
-
choices_admin_group = [item[1] for item in choices if item[0] == 'admin'][0]
|
|
24
|
-
assert choices_admin_group == (
|
|
25
|
-
('django_admin_log', 'LogEntry'),
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def test_get_table_choices():
|
|
30
|
-
choices = get_table_choices('auth_user')
|
|
31
|
-
assert 'columns' in choices
|
|
32
|
-
assert ('username', 'username', 'string') in choices['columns']
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
@pytest.mark.parametrize('field, expected_type', [
|
|
36
|
-
(models.AutoField(), 'integer'),
|
|
37
|
-
(models.BigAutoField(), 'integer'),
|
|
38
|
-
(models.BigIntegerField(), 'integer'),
|
|
39
|
-
(models.BooleanField(), 'boolean'),
|
|
40
|
-
(models.CharField(), 'string'),
|
|
41
|
-
(models.DateField(), 'string'),
|
|
42
|
-
(models.DateTimeField(), 'string'),
|
|
43
|
-
(models.DecimalField(), 'float'),
|
|
44
|
-
(models.EmailField(), 'string'),
|
|
45
|
-
(models.FloatField(), 'float'),
|
|
46
|
-
(models.ForeignKey('LogEntry', on_delete=models.CASCADE), 'string'),
|
|
47
|
-
(models.IntegerField(), 'integer'),
|
|
48
|
-
(models.GenericIPAddressField(), 'string'),
|
|
49
|
-
(models.NullBooleanField(), 'boolean'),
|
|
50
|
-
(models.PositiveIntegerField(), 'integer'),
|
|
51
|
-
(models.PositiveSmallIntegerField(), 'integer'),
|
|
52
|
-
(models.SlugField(), 'string'),
|
|
53
|
-
(models.SmallIntegerField(), 'integer'),
|
|
54
|
-
(models.TextField(), 'string'),
|
|
55
|
-
(models.TimeField(), 'string'),
|
|
56
|
-
(models.URLField(), 'string'),
|
|
57
|
-
(models.UUIDField(), 'string'),
|
|
58
|
-
])
|
|
59
|
-
def test_get_field_type(field, expected_type):
|
|
60
|
-
assert get_field_type(field) == expected_type
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def test_get_filter_params():
|
|
64
|
-
class ForeignModel(models.Model):
|
|
65
|
-
text1 = models.CharField()
|
|
66
|
-
text2 = models.CharField()
|
|
67
|
-
flag = models.BooleanField()
|
|
68
|
-
number = models.IntegerField()
|
|
69
|
-
|
|
70
|
-
class Model(models.Model):
|
|
71
|
-
other = models.ForeignKey(ForeignModel, on_delete=models.CASCADE)
|
|
72
|
-
name = models.CharField()
|
|
73
|
-
active = models.BooleanField()
|
|
74
|
-
age = models.IntegerField()
|
|
75
|
-
|
|
76
|
-
args, kwds = get_filter_params(Model, {
|
|
77
|
-
'other': 'abc',
|
|
78
|
-
'name': 'name',
|
|
79
|
-
'active': True,
|
|
80
|
-
'age': 123,
|
|
81
|
-
'non-existent-field': 'blah',
|
|
82
|
-
})
|
|
83
|
-
assert str(args) == str([
|
|
84
|
-
Q() | Q(other__text1__icontains='abc') | Q(other__text2__icontains='abc')
|
|
85
|
-
])
|
|
86
|
-
assert kwds == {
|
|
87
|
-
'name__icontains': 'name',
|
|
88
|
-
'active': True,
|
|
89
|
-
'age': 123,
|
|
90
|
-
}
|
cms_qe_video/tests/__init__.py
DELETED
|
File without changes
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
from django.core.exceptions import ValidationError
|
|
3
|
-
from pytest_data import use_data
|
|
4
|
-
|
|
5
|
-
from cms_qe_video.models import VIMEO, YOUTUBE
|
|
6
|
-
|
|
7
|
-
non_default_data = {
|
|
8
|
-
'controls': False,
|
|
9
|
-
'width': 500,
|
|
10
|
-
'height': 500,
|
|
11
|
-
'autoplay': True,
|
|
12
|
-
'loop': True,
|
|
13
|
-
'muted': True,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def test__get_attributes_str_to_html_with_default_attributes(cms_qe_video_source_file_video_player_model):
|
|
18
|
-
attr_str = cms_qe_video_source_file_video_player_model._get_attributes_str_to_html(
|
|
19
|
-
('width', 'height', 'controls', 'autoplay', 'loop', 'muted'))
|
|
20
|
-
assert 'width=500' not in attr_str and 'height=500' not in attr_str
|
|
21
|
-
assert 'controls' in attr_str
|
|
22
|
-
assert 'autoplay' not in attr_str
|
|
23
|
-
assert 'loop' not in attr_str
|
|
24
|
-
assert 'muted' not in attr_str
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
@use_data(cms_qe_video_source_file_video_player_model_data=non_default_data)
|
|
28
|
-
def test__get_attributes_str_to_html_with_non_default_attributes(cms_qe_video_source_file_video_player_model):
|
|
29
|
-
attr_str = cms_qe_video_source_file_video_player_model._get_attributes_str_to_html(
|
|
30
|
-
('width', 'height', 'controls', 'autoplay', 'loop', 'muted'))
|
|
31
|
-
assert 'width=500' in attr_str and 'height=500' in attr_str
|
|
32
|
-
assert 'controls' not in attr_str
|
|
33
|
-
assert 'autoplay' in attr_str
|
|
34
|
-
assert 'loop' in attr_str
|
|
35
|
-
assert 'muted' in attr_str
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def test__get_attributes_str_to_url_with_default_attributes(cms_qe_video_source_file_video_player_model):
|
|
39
|
-
attr_str = cms_qe_video_source_file_video_player_model._get_attributes_str_to_url(
|
|
40
|
-
('width', 'height', 'controls', 'autoplay', 'loop', 'muted'))
|
|
41
|
-
assert 'width' not in attr_str and 'height' not in attr_str
|
|
42
|
-
assert 'controls=1' in attr_str
|
|
43
|
-
assert 'autoplay' not in attr_str
|
|
44
|
-
assert 'loop' not in attr_str
|
|
45
|
-
assert 'muted' not in attr_str
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
@use_data(cms_qe_video_source_file_video_player_model_data=non_default_data)
|
|
49
|
-
def test__get_attributes_str_to_url_with_non_default_attributes(cms_qe_video_source_file_video_player_model):
|
|
50
|
-
attr_str = cms_qe_video_source_file_video_player_model._get_attributes_str_to_url(
|
|
51
|
-
('width', 'height', 'controls', 'autoplay', 'loop', 'muted'))
|
|
52
|
-
assert 'width=500' in attr_str and 'height=500' in attr_str
|
|
53
|
-
assert 'controls' not in attr_str
|
|
54
|
-
assert 'autoplay=1' in attr_str
|
|
55
|
-
assert 'loop=1' in attr_str
|
|
56
|
-
assert 'muted=1' in attr_str
|
|
57
|
-
assert attr_str.count('&') == 4
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
@use_data(
|
|
61
|
-
cms_qe_video_hosting_video_player_model_data={'video_hosting_service': YOUTUBE,
|
|
62
|
-
'video_url': 'isnotyoutube.com/somevideo', })
|
|
63
|
-
def test_clean_youtube_bad_url(cms_qe_video_hosting_video_player_model):
|
|
64
|
-
with pytest.raises(ValidationError) as validation_exception:
|
|
65
|
-
cms_qe_video_hosting_video_player_model.clean()
|
|
66
|
-
validation_exception.match(r'.*YouTube.*')
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
@use_data(
|
|
70
|
-
cms_qe_video_hosting_video_player_model_data={'video_hosting_service': VIMEO,
|
|
71
|
-
'video_url': 'notvimeo.com/somevideo', })
|
|
72
|
-
def test_clean_vimeo_bad_url(cms_qe_video_hosting_video_player_model):
|
|
73
|
-
with pytest.raises(ValidationError) as validation_exception:
|
|
74
|
-
cms_qe_video_hosting_video_player_model.clean()
|
|
75
|
-
validation_exception.match(r'.*Vimeo.*')
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
@use_data(cms_qe_video_hosting_video_player_model_data={'video_url': 'youtube.com/somevideo',
|
|
79
|
-
'video_hosting_service': YOUTUBE})
|
|
80
|
-
def test_clean_youtube_good_urls(cms_qe_video_hosting_video_player_model):
|
|
81
|
-
cms_qe_video_hosting_video_player_model.clean()
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
@use_data(cms_qe_video_hosting_video_player_model_data={'video_url': 'vimeo.com/somevideo',
|
|
85
|
-
'video_hosting_service': VIMEO})
|
|
86
|
-
def test_clean_vimeo_good_urls(cms_qe_video_hosting_video_player_model):
|
|
87
|
-
cms_qe_video_hosting_video_player_model.clean()
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
@use_data(cms_qe_video_hosting_video_player_model_data={'video_url': 'vimeo.com/somevideo',
|
|
91
|
-
'video_hosting_service': VIMEO,
|
|
92
|
-
'controls': False})
|
|
93
|
-
def test_clean_vimeo_disabled_controls(cms_qe_video_hosting_video_player_model):
|
|
94
|
-
with pytest.raises(ValidationError) as validation_exception:
|
|
95
|
-
cms_qe_video_hosting_video_player_model.clean()
|
|
96
|
-
validation_exception.match(r'.*Vimeo.*controls.*')
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import re
|
|
2
|
-
|
|
3
|
-
from pytest_data import use_data
|
|
4
|
-
|
|
5
|
-
from cms_qe_test import render_plugin
|
|
6
|
-
|
|
7
|
-
from ..cms_plugins import HostingVideoPlayerPlugin, SourceFileVideoPlayerPlugin
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@use_data(cms_qe_video_source_file_video_player_model_data={'source_file': None})
|
|
11
|
-
def test_render_source_file_video_plugin_without_source_file(cms_qe_video_source_file_video_player_model):
|
|
12
|
-
html = render_plugin(SourceFileVideoPlayerPlugin, cms_qe_video_source_file_video_player_model)
|
|
13
|
-
assert re.search(r'<p>Video file is missing</p>', html)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def test_render_source_file_video_plugin(cms_qe_video_source_file_video_player_model):
|
|
17
|
-
html = render_plugin(SourceFileVideoPlayerPlugin, cms_qe_video_source_file_video_player_model)
|
|
18
|
-
assert not re.search(r'<iframe(\s|.)*</iframe>', html)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def test_render_hosting_video_plugin(cms_qe_video_hosting_video_player_model):
|
|
22
|
-
html = render_plugin(HostingVideoPlayerPlugin, cms_qe_video_hosting_video_player_model)
|
|
23
|
-
assert not re.search(r'<video(\s|.)*</video>', html)
|
|
24
|
-
assert re.search(r'<iframe(\s|.)*</iframe>', html)
|