django-camomilla-cms 6.0.0b18__py2.py3-none-any.whl → 6.0.1__py2.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.
- camomilla/__init__.py +1 -1
- camomilla/models/page.py +1 -8
- camomilla/serializers/base/__init__.py +9 -5
- camomilla/settings.py +15 -2
- camomilla/templatetags/model_extras.py +8 -4
- camomilla/theme/__init__.py +1 -1
- camomilla/theme/admin/pages.py +20 -0
- camomilla/utils/templates.py +27 -7
- camomilla/views/base/__init__.py +4 -2
- camomilla/views/mixins/pagination.py +1 -1
- django_camomilla_cms-6.0.1.dist-info/METADATA +133 -0
- {django_camomilla_cms-6.0.0b18.dist-info → django_camomilla_cms-6.0.1.dist-info}/RECORD +26 -25
- {django_camomilla_cms-6.0.0b18.dist-info → django_camomilla_cms-6.0.1.dist-info}/WHEEL +1 -1
- tests/fixtures/__init__.py +3 -6
- tests/test_admin_page_form.py +63 -0
- tests/test_camomilla_filters.py +7 -3
- tests/test_media.py +54 -15
- tests/test_menu.py +33 -18
- tests/test_model_api.py +61 -16
- tests/test_model_api_permissions.py +7 -2
- tests/test_model_api_register.py +118 -156
- tests/test_pages.py +139 -131
- tests/test_templates_context.py +62 -24
- tests/test_utils.py +53 -83
- django_camomilla_cms-6.0.0b18.dist-info/METADATA +0 -79
- {django_camomilla_cms-6.0.0b18.dist-info → django_camomilla_cms-6.0.1.dist-info}/licenses/LICENSE +0 -0
- {django_camomilla_cms-6.0.0b18.dist-info → django_camomilla_cms-6.0.1.dist-info}/top_level.txt +0 -0
tests/test_utils.py
CHANGED
@@ -1,86 +1,56 @@
|
|
1
|
-
import
|
2
|
-
import mock
|
1
|
+
from camomilla.utils import get_host_url, get_complete_url, get_templates
|
3
2
|
|
4
|
-
from camomilla.utils import get_host_url, get_complete_url, get_page
|
5
|
-
from camomilla.exceptions import NeedARedirect
|
6
|
-
from camomilla.models import Page, Article
|
7
|
-
|
8
|
-
from django.http import Http404
|
9
3
|
from django.test import TestCase
|
10
4
|
from django.test import RequestFactory
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
# request_factory = RequestFactory()
|
64
|
-
# request = request_factory.get("/path")
|
65
|
-
# request.META["HTTP_HOST"] = "localhost"
|
66
|
-
# article = Article.objects.create(permalink="main")
|
67
|
-
# article.canonical = "/myarticle"
|
68
|
-
# article.og_url = "/myarticle"
|
69
|
-
# article.save()
|
70
|
-
# article = Article.get(request, permalink="main")
|
71
|
-
# self.assertEqual(article.og_url, "http://localhost/myarticle")
|
72
|
-
# self.assertEqual(article.canonical, "http://localhost/myarticle")
|
73
|
-
|
74
|
-
# def test_get_article_with_redirect(self):
|
75
|
-
# """Our beloved get_seo utility with auto attributes"""
|
76
|
-
# request_factory = RequestFactory()
|
77
|
-
# request = request_factory.get("/articles/articolo-1")
|
78
|
-
# request.META["HTTP_HOST"] = "localhost"
|
79
|
-
|
80
|
-
# article = Article.objects.create(permalink="article-1", language_code="en")
|
81
|
-
# article.translate("it")
|
82
|
-
# article.permalink = "articolo-1"
|
83
|
-
# article.save()
|
84
|
-
# self.assertRaises(NeedARedirect, Article.get, request, permalink="article-1")
|
85
|
-
# activate("de")
|
86
|
-
# self.assertRaises(Http404, Article.get, request, permalink="article-1")
|
5
|
+
import responses
|
6
|
+
from camomilla.settings import INTEGRATIONS_ASTRO_URL
|
7
|
+
|
8
|
+
|
9
|
+
class UtilsTestCase(TestCase):
|
10
|
+
def setUp(self):
|
11
|
+
self.astro_api_url = INTEGRATIONS_ASTRO_URL + "/api/templates"
|
12
|
+
|
13
|
+
def test_get_host_url(self):
|
14
|
+
request_factory = RequestFactory()
|
15
|
+
request = request_factory.get("/path")
|
16
|
+
request.META["HTTP_HOST"] = "localhost"
|
17
|
+
host_url = get_host_url(request)
|
18
|
+
self.assertEqual(host_url, "http://localhost")
|
19
|
+
host_url = get_host_url(None)
|
20
|
+
self.assertEqual(host_url, None)
|
21
|
+
|
22
|
+
def test_get_complete_url(self):
|
23
|
+
request_factory = RequestFactory()
|
24
|
+
request = request_factory.get("/path")
|
25
|
+
request.META["HTTP_HOST"] = "localhost"
|
26
|
+
complete_url = get_complete_url(request, "path")
|
27
|
+
self.assertEqual(complete_url, "http://localhost/path")
|
28
|
+
complete_url = get_complete_url(request, "path", "it")
|
29
|
+
self.assertEqual(complete_url, "http://localhost/it/path")
|
30
|
+
complete_url = get_complete_url(request, "path", "fr")
|
31
|
+
self.assertEqual(complete_url, "http://localhost/fr/path")
|
32
|
+
|
33
|
+
@responses.activate
|
34
|
+
def test_get_all_templates_files_error(self):
|
35
|
+
responses.add(
|
36
|
+
responses.GET,
|
37
|
+
self.astro_api_url,
|
38
|
+
json=["Error"],
|
39
|
+
status=400,
|
40
|
+
)
|
41
|
+
templates = get_templates(request=RequestFactory().get("/"))
|
42
|
+
self.assertFalse("Astro: Error" in templates)
|
43
|
+
self.assertEqual(responses.calls[0].request.url, self.astro_api_url)
|
44
|
+
|
45
|
+
@responses.activate
|
46
|
+
def test_get_all_templates_files(self):
|
47
|
+
responses.add(
|
48
|
+
responses.GET,
|
49
|
+
self.astro_api_url,
|
50
|
+
json=["mock_template/1", "mock_template/2"],
|
51
|
+
status=200,
|
52
|
+
)
|
53
|
+
templates = get_templates(request=RequestFactory().get("/"))
|
54
|
+
self.assertTrue("mock_template/1" in templates)
|
55
|
+
self.assertTrue("mock_template/2" in templates)
|
56
|
+
self.assertEqual(responses.calls[0].request.url, self.astro_api_url)
|
@@ -1,79 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: django-camomilla-cms
|
3
|
-
Version: 6.0.0b18
|
4
|
-
Summary: Django powered cms
|
5
|
-
Author-email: Lotrèk <dimmitutto@lotrek.it>
|
6
|
-
License: MIT
|
7
|
-
Project-URL: Homepage, https://github.com/camomillacms/camomilla-core
|
8
|
-
Keywords: cms,django,api cms
|
9
|
-
Classifier: Environment :: Web Environment
|
10
|
-
Classifier: Framework :: Django
|
11
|
-
Classifier: Intended Audience :: Developers
|
12
|
-
Classifier: Programming Language :: Python
|
13
|
-
Classifier: Programming Language :: Python :: 3
|
14
|
-
Requires-Python: <=3.13,>=3.8
|
15
|
-
Description-Content-Type: text/markdown
|
16
|
-
License-File: LICENSE
|
17
|
-
Requires-Dist: django-modeltranslation<=0.18.12,>=0.18.7
|
18
|
-
Requires-Dist: djsuperadmin<1.0.0,>=0.9
|
19
|
-
Requires-Dist: djangorestframework<=3.14.0,>=3.10.0
|
20
|
-
Requires-Dist: django-structured-json-field>=0.4.1
|
21
|
-
Requires-Dist: Pillow>=10.0.0
|
22
|
-
Requires-Dist: django-admin-interface<1.0.0,>=0.26.0
|
23
|
-
Requires-Dist: django-ckeditor<7.0.0,>=5.7.1
|
24
|
-
Requires-Dist: django-tinymce<5.0.0,>=4.1.0
|
25
|
-
Requires-Dist: python-magic<0.5,>=0.4
|
26
|
-
Requires-Dist: Django<6,>=3.2
|
27
|
-
Requires-Dist: django_jsonform>=2.23
|
28
|
-
Dynamic: license-file
|
29
|
-
|
30
|
-
# camomilla django cms [](https://pypi.org/project/django-camomilla-cms)   [](./LICENSE)
|
31
|
-
|
32
|
-
## Install
|
33
|
-
|
34
|
-
```shell
|
35
|
-
$ pip install django-camomilla-cms
|
36
|
-
```
|
37
|
-
|
38
|
-
## Setup
|
39
|
-
```shell
|
40
|
-
$ mkdir -p camomilla_migrations
|
41
|
-
$ touch camomilla_migrations/__init__.py
|
42
|
-
$ python manage.py makemigrations camomilla
|
43
|
-
$ python manage.py migrate camomilla
|
44
|
-
```
|
45
|
-
|
46
|
-
|
47
|
-
## Settings
|
48
|
-
|
49
|
-
Camomilla brings a lot of default settings you can include in your project's ones
|
50
|
-
|
51
|
-
from camomilla.defaults import *
|
52
|
-
|
53
|
-
Remember to add all the required applications in your project
|
54
|
-
|
55
|
-
```python
|
56
|
-
INSTALLED_APPS = [
|
57
|
-
...
|
58
|
-
'camomilla', # always needed
|
59
|
-
'camomilla.theme', # needed to customize admin interface
|
60
|
-
'djsuperadmin', # needed if you whant to use djsuperadmin for contents
|
61
|
-
'modeltranslation', # needed if your website is multilanguage (can be added later)
|
62
|
-
'rest_framework', # always needed
|
63
|
-
'rest_framework.authtoken', # always needed
|
64
|
-
...
|
65
|
-
]
|
66
|
-
```
|
67
|
-
|
68
|
-
## Run the server
|
69
|
-
|
70
|
-
$ python manage.py runserver
|
71
|
-
|
72
|
-
## Run tests
|
73
|
-
|
74
|
-
pip install -r requirements-dev.txt
|
75
|
-
make test
|
76
|
-
|
77
|
-
## Run format with black
|
78
|
-
|
79
|
-
black camomilla
|
{django_camomilla_cms-6.0.0b18.dist-info → django_camomilla_cms-6.0.1.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
{django_camomilla_cms-6.0.0b18.dist-info → django_camomilla_cms-6.0.1.dist-info}/top_level.txt
RENAMED
File without changes
|