drf-appkit 1.3.9__tar.gz → 1.4.1__tar.gz
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.
- {drf-appkit-1.3.9/drf_appkit.egg-info → drf-appkit-1.4.1}/PKG-INFO +1 -1
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/api/tests.py +1 -95
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/forms/widgets.py +10 -4
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/models.py +8 -0
- drf-appkit-1.4.1/appkit/tests.py +141 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1/drf_appkit.egg-info}/PKG-INFO +1 -1
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/setup.cfg +1 -1
- drf-appkit-1.3.9/appkit/tests.py +0 -20
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/LICENSE +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/MANIFEST.in +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/README.md +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/__init__.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/api/__init__.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/api/filters.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/api/mixins.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/api/pagination.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/api/relations.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/api/renderers.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/api/serializers.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/api/views.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/apps.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/auth/__init__.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/auth/backends.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/auth/decorators.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/auth/email.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/auth/permissions.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/debug.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/drf/__init__.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/drf/adapters.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/drf/authentication.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/drf/backends.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/drf/endpoints.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/drf/exceptions.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/drf/fields.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/drf/filters.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/drf/mixins.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/drf/permissions.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/drf/serializers.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/drf_appkit.egg-info/PKG-INFO +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/drf_appkit.egg-info/SOURCES.txt +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/drf_appkit.egg-info/dependency_links.txt +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/drf_appkit.egg-info/top_level.txt +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/forms/__init__.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/handlers.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/jinja2/appkit/forms/widgets/money_widget.html +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/managers.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0001_initial.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0002_arrangement_tags.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0003_auto_20210221_0852.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0004_auto_20210309_0655.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0005_auto_20210324_1046.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0006_sitealias.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0007_auto_20211021_1901.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0008_update_autofields.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0009_alter_arrangement_unique_together_and_more.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0010_arrangement_name.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0011_alter_sitealias_options.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0012_alter_sitealias_site.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0013_usergroup.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0014_remove_note_notes_note_content_type_note_object_id.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0015_alter_note_content_type_alter_note_object_id.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0016_alter_arrangementitem_unique_together_and_more.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0017_alter_imageattachment_image.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0018_place_geoposition.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0019_alter_place_geoposition.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0020_remove_arrangement_type_arrangement_content_type.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0021_rename_content_type_arrangement_item_type.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/0022_imageattachment_rendition_key_imageattachment_warm.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/migrations/__init__.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/notification.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/settings.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/shortcuts.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/storages.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/tasks.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/transformers.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/util.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/appkit/views.py +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/drf_appkit.egg-info/SOURCES.txt +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/drf_appkit.egg-info/dependency_links.txt +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/drf_appkit.egg-info/top_level.txt +0 -0
- {drf-appkit-1.3.9 → drf-appkit-1.4.1}/setup.py +0 -0
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import shutil
|
|
3
|
-
|
|
4
|
-
from django.conf import settings
|
|
5
1
|
from django.contrib.auth import get_user_model
|
|
6
|
-
from django.contrib.auth.models import Group
|
|
7
|
-
from django.contrib.sites.models import Site
|
|
8
|
-
|
|
9
2
|
from django.db import models
|
|
10
3
|
from django.urls import reverse
|
|
11
|
-
from django.utils.text import slugify
|
|
12
4
|
|
|
13
5
|
from rest_framework.test import (
|
|
14
6
|
APIRequestFactory,
|
|
@@ -17,7 +9,7 @@ from rest_framework.test import (
|
|
|
17
9
|
from rest_framework_simplejwt.tokens import RefreshToken
|
|
18
10
|
|
|
19
11
|
from ..auth import get_userprofile_model
|
|
20
|
-
from ..models import Document
|
|
12
|
+
from ..models import Document
|
|
21
13
|
|
|
22
14
|
User = get_user_model()
|
|
23
15
|
UserProfile = get_userprofile_model()
|
|
@@ -32,8 +24,6 @@ It may be used in a situation where a body
|
|
|
32
24
|
of text is expected (such as a comment).
|
|
33
25
|
"""
|
|
34
26
|
|
|
35
|
-
DEFAULT_USER_PASSWORD = 'asdf;#KLVCSUkal3dsfui#@FS@!'
|
|
36
|
-
|
|
37
27
|
|
|
38
28
|
class TestCaseAssertionMixin(object):
|
|
39
29
|
"""
|
|
@@ -71,38 +61,6 @@ class TestCaseAssertionMixin(object):
|
|
|
71
61
|
|
|
72
62
|
|
|
73
63
|
class APITestCase(TestCaseAssertionMixin, DRFAPITestCase):
|
|
74
|
-
site = None
|
|
75
|
-
|
|
76
|
-
@classmethod
|
|
77
|
-
def setUpTestData(cls):
|
|
78
|
-
cls.superuser = User._default_manager.db_manager().create_superuser(**{
|
|
79
|
-
User.USERNAME_FIELD: 'super-user',
|
|
80
|
-
User.EMAIL_FIELD: 'superuser@appkit.com',
|
|
81
|
-
'first_name': 'Super',
|
|
82
|
-
'last_name': 'User',
|
|
83
|
-
'password': DEFAULT_USER_PASSWORD,
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
cls.site = Site.objects.create(
|
|
87
|
-
name='Test Site',
|
|
88
|
-
domain='testserver'
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
UserProfile.objects.create(user=cls.superuser)
|
|
92
|
-
|
|
93
|
-
@classmethod
|
|
94
|
-
def tearDownClass(cls):
|
|
95
|
-
# Clear any test media that was generated
|
|
96
|
-
test_media_paths = [
|
|
97
|
-
os.path.join(settings.MEDIA_ROOT, '__sized__', 'test'),
|
|
98
|
-
os.path.join(settings.MEDIA_ROOT, 'test'),
|
|
99
|
-
]
|
|
100
|
-
for media_path in test_media_paths:
|
|
101
|
-
if os.path.exists(media_path):
|
|
102
|
-
shutil.rmtree(media_path)
|
|
103
|
-
|
|
104
|
-
super().tearDownClass()
|
|
105
|
-
|
|
106
64
|
def _logout(self):
|
|
107
65
|
self.access_token = None
|
|
108
66
|
self.refresh_token = None
|
|
@@ -111,58 +69,6 @@ class APITestCase(TestCaseAssertionMixin, DRFAPITestCase):
|
|
|
111
69
|
super().setUp()
|
|
112
70
|
self._logout()
|
|
113
71
|
|
|
114
|
-
def create_user(self, first_name='TestUser', last_name='', email=None, phone=None,
|
|
115
|
-
is_active=True, is_staff=False, site=None, created_by=None):
|
|
116
|
-
full_name = '{} {}'.format(first_name, last_name)
|
|
117
|
-
username = slugify(full_name)
|
|
118
|
-
|
|
119
|
-
user = User.objects.create(
|
|
120
|
-
username=username,
|
|
121
|
-
email=email if email else '{}@noundb.com'.format(username),
|
|
122
|
-
first_name=first_name,
|
|
123
|
-
last_name=last_name,
|
|
124
|
-
is_active=is_active,
|
|
125
|
-
is_staff=is_staff,
|
|
126
|
-
)
|
|
127
|
-
user.set_password(DEFAULT_USER_PASSWORD)
|
|
128
|
-
user.save()
|
|
129
|
-
|
|
130
|
-
UserProfile.objects.create(
|
|
131
|
-
created_by=created_by if created_by else self.superuser,
|
|
132
|
-
site=site if site else self.site,
|
|
133
|
-
user=user,
|
|
134
|
-
phone=phone,
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
return user
|
|
138
|
-
|
|
139
|
-
def create_tpb_users(self):
|
|
140
|
-
TRAILER_PARK_BOYS = (
|
|
141
|
-
{'first_name': 'Jim', 'last_name': 'Lahey', 'is_staff': True, 'phone': '+17825556969'},
|
|
142
|
-
{'first_name': 'Randy', 'last_name': 'BoBandy', 'is_staff': False},
|
|
143
|
-
{'first_name': 'Sam', 'last_name': 'Lasco', 'is_staff': False, 'phone': '+17825551234'},
|
|
144
|
-
{'first_name': 'Ricky', 'is_staff': False},
|
|
145
|
-
{'first_name': 'Julian', 'is_staff': False},
|
|
146
|
-
{'first_name': 'Bubbles', 'is_staff': False},
|
|
147
|
-
)
|
|
148
|
-
|
|
149
|
-
tpb_users = {}
|
|
150
|
-
for user_info in TRAILER_PARK_BOYS:
|
|
151
|
-
user = self.create_user(**user_info)
|
|
152
|
-
tpb_users[user.username] = user
|
|
153
|
-
|
|
154
|
-
tpb_group = Group.objects.create(name='trailer-park-boys')
|
|
155
|
-
tpb_group.user_set.add(*tpb_users.values())
|
|
156
|
-
self.tpb_group = tpb_group
|
|
157
|
-
|
|
158
|
-
self.tpb_usergroup = UserGroup.objects.create(
|
|
159
|
-
created_by=self.superuser,
|
|
160
|
-
site=self.site,
|
|
161
|
-
group=tpb_group
|
|
162
|
-
)
|
|
163
|
-
|
|
164
|
-
return tpb_users
|
|
165
|
-
|
|
166
72
|
def url_namespace(self):
|
|
167
73
|
return None
|
|
168
74
|
|
|
@@ -12,15 +12,21 @@ class MoneyWidget(MultiWidget):
|
|
|
12
12
|
def __init__(
|
|
13
13
|
self,
|
|
14
14
|
choices=CURRENCY_CHOICES,
|
|
15
|
-
amount_widget=
|
|
16
|
-
'class': 'border-0 py-3 pl-7 pr-20 w-full',
|
|
17
|
-
'pattern': '[0-9\.]*',
|
|
18
|
-
}),
|
|
15
|
+
amount_widget=None,
|
|
19
16
|
currency_widget=None,
|
|
20
17
|
default_currency=None,
|
|
18
|
+
step=1,
|
|
21
19
|
*args,
|
|
22
20
|
**kwargs
|
|
23
21
|
):
|
|
22
|
+
if not amount_widget:
|
|
23
|
+
widget_attrs = {
|
|
24
|
+
'class': 'border-0 py-3 pl-7 pr-20 w-full',
|
|
25
|
+
}
|
|
26
|
+
if isinstance(step, int):
|
|
27
|
+
widget_attrs['pattern'] = '[0-9]*'
|
|
28
|
+
amount_widget = TextInput(attrs=widget_attrs)
|
|
29
|
+
|
|
24
30
|
self.default_currency = default_currency
|
|
25
31
|
if not currency_widget:
|
|
26
32
|
currency_widget = Select(choices=choices, attrs={
|
|
@@ -36,6 +36,14 @@ from .settings import appkit_settings
|
|
|
36
36
|
class ModelBase(models.Model):
|
|
37
37
|
notification_classes = {}
|
|
38
38
|
|
|
39
|
+
@classmethod
|
|
40
|
+
def include_related_users_as_notification_subscribers(cls, recipients, notification_name, sender):
|
|
41
|
+
"""
|
|
42
|
+
Implicitly include a document's assigned recipients in the set of notification subscribers
|
|
43
|
+
"""
|
|
44
|
+
if sender:
|
|
45
|
+
recipients.update(sender.related_users)
|
|
46
|
+
|
|
39
47
|
class Meta:
|
|
40
48
|
abstract = True
|
|
41
49
|
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import shutil
|
|
3
|
+
|
|
4
|
+
from django.conf import settings
|
|
5
|
+
from django.test import TestCase
|
|
6
|
+
from django.contrib.auth import get_user_model
|
|
7
|
+
from django.contrib.auth.models import Group
|
|
8
|
+
from django.contrib.sites.models import Site
|
|
9
|
+
from django.utils.text import slugify
|
|
10
|
+
|
|
11
|
+
from .util import to_gsm7
|
|
12
|
+
|
|
13
|
+
from .auth import get_userprofile_model
|
|
14
|
+
from .settings import appkit_settings
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
SiteProfile = appkit_settings.SITEPROFILE_MODEL
|
|
18
|
+
User = get_user_model()
|
|
19
|
+
UserProfile = get_userprofile_model()
|
|
20
|
+
|
|
21
|
+
DEFAULT_USER_PASSWORD = 'asdf;#KLVCSUkal3dsfui#@FS@!'
|
|
22
|
+
DEFAULT_SITE_NAME = 'My App'
|
|
23
|
+
DEFAULT_SITE_DOMAIN = 'testserver' # IMPORTANT: this matches the hostname generated by the test runner
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class AppkitTestCaseMixin(object):
|
|
27
|
+
site = None
|
|
28
|
+
site_profile = None
|
|
29
|
+
superuser = None
|
|
30
|
+
|
|
31
|
+
@classmethod
|
|
32
|
+
def setUpTestData(cls):
|
|
33
|
+
cls.superuser = User._default_manager.db_manager().create_superuser(**{
|
|
34
|
+
User.USERNAME_FIELD: 'super-user',
|
|
35
|
+
User.EMAIL_FIELD: 'superuser@appkit.com',
|
|
36
|
+
'first_name': 'Super',
|
|
37
|
+
'last_name': 'User',
|
|
38
|
+
'password': DEFAULT_USER_PASSWORD,
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
cls.site = Site.objects.create(name=DEFAULT_SITE_NAME, domain=DEFAULT_SITE_DOMAIN)
|
|
42
|
+
cls.site_profile = SiteProfile.objects.create(created_by=cls.superuser, site=cls.site)
|
|
43
|
+
|
|
44
|
+
UserProfile.objects.create(
|
|
45
|
+
created_by=cls.superuser,
|
|
46
|
+
site=cls.site,
|
|
47
|
+
user=cls.superuser,
|
|
48
|
+
phone='+18005551234'
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
@classmethod
|
|
52
|
+
def tearDownClass(cls):
|
|
53
|
+
# Clear any test media that was generated
|
|
54
|
+
test_media_paths = [
|
|
55
|
+
os.path.join(settings.MEDIA_ROOT, '__sized__', 'test'),
|
|
56
|
+
os.path.join(settings.MEDIA_ROOT, 'test'),
|
|
57
|
+
]
|
|
58
|
+
for media_path in test_media_paths:
|
|
59
|
+
if os.path.exists(media_path):
|
|
60
|
+
shutil.rmtree(media_path)
|
|
61
|
+
|
|
62
|
+
super().tearDownClass()
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def create_document(self, DocumentClass, **kwargs):
|
|
66
|
+
defaults = {
|
|
67
|
+
'created_by': self.superuser,
|
|
68
|
+
'site': self.site
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
document_info = dict(defaults)
|
|
72
|
+
document_info.update(kwargs)
|
|
73
|
+
return DocumentClass.objects.create(**document_info)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def create_site(self, name=DEFAULT_SITE_NAME, domain=DEFAULT_SITE_DOMAIN):
|
|
77
|
+
site = Site.objects.create(name=name, domain=domain)
|
|
78
|
+
self.create_document(SiteProfile, site=site)
|
|
79
|
+
return site
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def create_user(self, first_name='TestUser', last_name='', email=None, phone=None,
|
|
83
|
+
is_active=True, is_staff=False, site=None, created_by=None):
|
|
84
|
+
full_name = '{} {}'.format(first_name, last_name)
|
|
85
|
+
username = slugify(full_name)
|
|
86
|
+
|
|
87
|
+
user = User._default_manager.db_manager().create_user(**{
|
|
88
|
+
User.USERNAME_FIELD: username,
|
|
89
|
+
User.EMAIL_FIELD: email if email else f'{username}@noundb.com',
|
|
90
|
+
'first_name': first_name,
|
|
91
|
+
'last_name': last_name,
|
|
92
|
+
'is_active': is_active,
|
|
93
|
+
'is_staff': is_staff,
|
|
94
|
+
'password': DEFAULT_USER_PASSWORD,
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
UserProfile.objects.create(
|
|
98
|
+
created_by=created_by if created_by else self.superuser,
|
|
99
|
+
site=site if site else self.site,
|
|
100
|
+
user=user,
|
|
101
|
+
phone=phone,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
return user
|
|
105
|
+
|
|
106
|
+
def create_tpb_users(self):
|
|
107
|
+
TRAILER_PARK_BOYS = (
|
|
108
|
+
{'first_name': 'Jim', 'last_name': 'Lahey', 'is_staff': True, 'phone': '+17825556969'},
|
|
109
|
+
{'first_name': 'Randy', 'last_name': 'BoBandy', 'is_staff': False},
|
|
110
|
+
{'first_name': 'Sam', 'last_name': 'Lasco', 'is_staff': False, 'phone': '+17825551234'},
|
|
111
|
+
{'first_name': 'Ricky', 'is_staff': False},
|
|
112
|
+
{'first_name': 'Julian', 'is_staff': False},
|
|
113
|
+
{'first_name': 'Bubbles', 'is_staff': False},
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
tpb_users = {}
|
|
117
|
+
for user_info in TRAILER_PARK_BOYS:
|
|
118
|
+
user = self.create_user(**user_info)
|
|
119
|
+
tpb_users[user.username] = user
|
|
120
|
+
|
|
121
|
+
tpb_group = Group.objects.create(name='trailer-park-boys')
|
|
122
|
+
tpb_group.user_set.add(*tpb_users.values())
|
|
123
|
+
self.tpb_group = tpb_group
|
|
124
|
+
|
|
125
|
+
return tpb_users
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class GSMTestCase(TestCase):
|
|
129
|
+
VALID_GSM_STRING = 'This message contains only GSM-7 characters'
|
|
130
|
+
INVALID_GSM_STRING = "🥳 [It's] a $#!T 🥳 party 🥳"
|
|
131
|
+
|
|
132
|
+
def test_gsm7_to_gsm7(self):
|
|
133
|
+
self.assertEqual(self.VALID_GSM_STRING, to_gsm7(self.VALID_GSM_STRING))
|
|
134
|
+
|
|
135
|
+
def test_emoji_to_gsm7(self):
|
|
136
|
+
# Note that leading and trailing whitespace are valid and therefore _NOT_ removed
|
|
137
|
+
self.assertEqual(to_gsm7(self.INVALID_GSM_STRING), " [It's] a $#!T party ")
|
|
138
|
+
|
|
139
|
+
def test_to_gsm7_max_length(self):
|
|
140
|
+
gsm_msg = to_gsm7(to_gsm7(self.INVALID_GSM_STRING), max_length=18)
|
|
141
|
+
self.assertEqual(gsm_msg, " [It's] a $#!T pa")
|
drf-appkit-1.3.9/appkit/tests.py
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
from django.test import TestCase
|
|
2
|
-
|
|
3
|
-
from .util import to_gsm7
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
VALID_GSM_STRING = 'This message contains only GSM-7 characters'
|
|
7
|
-
INVALID_GSM_STRING = "🥳 [It's] a $#!T 🥳 party 🥳"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class GSMTestCase(TestCase):
|
|
11
|
-
def test_gsm7_to_gsm7(self):
|
|
12
|
-
self.assertEqual(VALID_GSM_STRING, to_gsm7(VALID_GSM_STRING))
|
|
13
|
-
|
|
14
|
-
def test_emoji_to_gsm7(self):
|
|
15
|
-
# Note that leading and trailing whitespace are valid and therefore _NOT_ removed
|
|
16
|
-
self.assertEqual(to_gsm7(INVALID_GSM_STRING), " [It's] a $#!T party ")
|
|
17
|
-
|
|
18
|
-
def test_to_gsm7_max_length(self):
|
|
19
|
-
gsm_msg = to_gsm7(to_gsm7(INVALID_GSM_STRING), max_length=18)
|
|
20
|
-
self.assertEqual(gsm_msg, " [It's] a $#!T pa")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|