django-camomilla-cms 6.0.0b17__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.
tests/test_utils.py CHANGED
@@ -1,86 +1,56 @@
1
- import os
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
- from django.utils.translation import activate, get_language
12
-
13
- from requests import RequestException
14
-
15
-
16
- # class UtilsTestCase(TestCase):
17
- # def setUp(self):
18
- # pass
19
-
20
- # def test_get_host_url(self):
21
- # """Our beloved get_host_url utility"""
22
- # request_factory = RequestFactory()
23
- # request = request_factory.get("/path")
24
- # request.META["HTTP_HOST"] = "localhost"
25
- # host_url = get_host_url(request)
26
- # self.assertEqual(host_url, "http://localhost")
27
- # host_url = get_host_url(None)
28
- # self.assertEqual(host_url, None)
29
-
30
- # def test_get_complete_url(self):
31
- # """Our beloved get_complete_url utility"""
32
- # request_factory = RequestFactory()
33
- # request = request_factory.get("/path")
34
- # request.META["HTTP_HOST"] = "localhost"
35
- # complete_url = get_complete_url(request, "path")
36
- # self.assertEqual(complete_url, "http://localhost/path")
37
- # complete_url = get_complete_url(request, "path", "it")
38
- # self.assertEqual(complete_url, "http://localhost/path")
39
- # complete_url = get_complete_url(request, "path", "fr")
40
- # self.assertEqual(complete_url, "http://localhost/fr/path")
41
-
42
- # def test_get_page_with_default_seo(self):
43
- # """Our beloved get_seo utility with auto attributes"""
44
- # request_factory = RequestFactory()
45
- # request = request_factory.get("/path")
46
- # request.META["HTTP_HOST"] = "localhost"
47
- # page = Page.get(request, identifier="home")
48
- # self.assertEqual(page.og_url, "http://localhost/path")
49
- # self.assertEqual(page.canonical, "http://localhost/path")
50
-
51
- # def test_get_article_with_default_seo(self):
52
- # """Our beloved get_seo utility with auto attributes"""
53
- # request_factory = RequestFactory()
54
- # request = request_factory.get("/path")
55
- # request.META["HTTP_HOST"] = "localhost"
56
- # Article.objects.create(permalink="main")
57
- # article = Article.get(request, permalink="main")
58
- # self.assertEqual(article.og_url, "http://localhost/path")
59
- # self.assertEqual(article.canonical, "http://localhost/path")
60
-
61
- # def test_compile_seo_overwrite(self):
62
- # """Our beloved get_seo utility with auto attributes"""
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)
tests/utils/media.py CHANGED
@@ -2,8 +2,9 @@ import os
2
2
  from tests.fixtures import load_asset
3
3
  from django.conf import settings
4
4
 
5
+
5
6
  def load_asset_and_remove_media(filename):
6
- asset = load_asset(filename)
7
- if os.path.exists(f"{settings.MEDIA_ROOT}/{filename}"):
8
- os.remove(f"{settings.MEDIA_ROOT}/{filename}")
9
- return asset
7
+ asset = load_asset(filename)
8
+ if os.path.exists(f"{settings.MEDIA_ROOT}/{filename}"):
9
+ os.remove(f"{settings.MEDIA_ROOT}/{filename}")
10
+ return asset
@@ -1,79 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: django-camomilla-cms
3
- Version: 6.0.0b17
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 [![PyPI](https://img.shields.io/pypi/v/django-camomilla-cms?style=flat-square)](https://pypi.org/project/django-camomilla-cms) ![Codecov](https://img.shields.io/codecov/c/github/camomillacms/camomilla-core?style=flat-square) ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/camomillacms/camomilla-core/Test,%20Coverage%20and%20Release?style=flat-square) [![GitHub](https://img.shields.io/github/license/camomillacms/camomilla-core?style=flat-square)](./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