Skip to content

Commit

Permalink
ci: pre-commit autoupdate (#144)
Browse files Browse the repository at this point in the history
* ci: pre-commit autoupdate

updates:
- [github.com/asottile/pyupgrade: v3.4.0 → v3.15.0](asottile/pyupgrade@v3.4.0...v3.15.0)
- [github.com/adamchainz/django-upgrade: 1.13.0 → 1.15.0](adamchainz/django-upgrade@1.13.0...1.15.0)
- https://github.com/charliermarsh/ruff-pre-commithttps://github.com/astral-sh/ruff-pre-commit
- [github.com/astral-sh/ruff-pre-commit: v0.0.270 → v0.1.4](astral-sh/ruff-pre-commit@v0.0.270...v0.1.4)
- [github.com/astral-sh/ruff-pre-commit: v0.1.2 → v0.1.4](astral-sh/ruff-pre-commit@v0.1.2...v0.1.4)
- [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](pre-commit/pre-commit-hooks@v4.4.0...v4.5.0)

* ci: auto fixes from pre-commit hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] authored Nov 7, 2023
1 parent 916e126 commit 5ff1bac
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ Use 'x' to check each item: [x] I have ...
* [ ] I have opened this pull request against ``master``
* [ ] I have added or modified the tests when changing logic
* [ ] I have followed [the conventional commits guidelines](https://www.conventionalcommits.org/) to add meaningful information into the changelog
* [ ] I have read the [contribution guidelines ](https://github.com/django-cms/django-cms/blob/develop/CONTRIBUTING.rst) and I have joined #workgroup-pr-review on
* [ ] I have read the [contribution guidelines ](https://github.com/django-cms/django-cms/blob/develop/CONTRIBUTING.rst) and I have joined #workgroup-pr-review on
[Slack](https://www.django-cms.org/slack) to find a “pr review buddy” who is going to review my pull request.
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@ ci:

repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.4.0
rev: v3.15.0
hooks:
- id: pyupgrade
args: ["--py38-plus"]

- repo: https://github.com/adamchainz/django-upgrade
rev: '1.13.0'
rev: '1.15.0'
hooks:
- id: django-upgrade
args: [--target-version, "3.2"]

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.270"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.4"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.2
rev: v0.1.4
hooks:
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand Down
14 changes: 7 additions & 7 deletions aldryn_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ class Form(forms.BaseForm):
required=False,
)
enable_search = forms.CheckboxField(
'Enable snippet content to be searchable.',
"Enable snippet content to be searchable.",
required=False,
initial=False,
)

def to_settings(self, data, settings):
if data['editor_theme']:
settings['DJANGOCMS_SNIPPET_THEME'] = data['editor_theme']
if data['editor_mode']:
settings['DJANGOCMS_SNIPPET_MODE'] = data['editor_mode']
if data['enable_search']:
settings['DJANGOCMS_SNIPPET_SEARCH'] = data['enable_search']
if data["editor_theme"]:
settings["DJANGOCMS_SNIPPET_THEME"] = data["editor_theme"]
if data["editor_mode"]:
settings["DJANGOCMS_SNIPPET_MODE"] = data["editor_mode"]
if data["enable_search"]:
settings["DJANGOCMS_SNIPPET_SEARCH"] = data["enable_search"]
return settings
25 changes: 14 additions & 11 deletions tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
#!/usr/bin/env python
HELPER_SETTINGS = {
'INSTALLED_APPS': [
'tests.utils',
"INSTALLED_APPS": [
"tests.utils",
],
'CMS_LANGUAGES': {
1: [{
'code': 'en',
'name': 'English',
}]
"CMS_LANGUAGES": {
1: [
{
"code": "en",
"name": "English",
}
]
},
'LANGUAGE_CODE': 'en',
'ALLOWED_HOSTS': ['localhost'],
"LANGUAGE_CODE": "en",
"ALLOWED_HOSTS": ["localhost"],
}


def run():
from app_helper import runner
runner.cms('djangocms_snippet')

runner.cms("djangocms_snippet")

if __name__ == '__main__':

if __name__ == "__main__":
run()
17 changes: 8 additions & 9 deletions tests/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,23 @@


class MigrationTestCase(TestCase):

@override_settings(MIGRATION_MODULES={})
def test_for_missing_migrations(self):
output = StringIO()
options = {
'interactive': False,
'dry_run': True,
'stdout': output,
'check_changes': True,
"interactive": False,
"dry_run": True,
"stdout": output,
"check_changes": True,
}

try:
call_command('makemigrations', **options)
call_command("makemigrations", **options)
except SystemExit as e:
status_code = str(e)
else:
# the "no changes" exit code is 0
status_code = '0'
status_code = "0"

if status_code == '1':
self.fail('There are missing migrations:\n {}'.format(output.getvalue()))
if status_code == "1":
self.fail(f"There are missing migrations:\n {output.getvalue()}")
1 change: 0 additions & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class SnippetModelTestCase(TestCase):

def setUp(self):
pass

Expand Down
34 changes: 25 additions & 9 deletions tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class SnippetPluginsTestCase(CMSTestCase):

def setUp(self):
self.language = "en"
self.home = create_page(
Expand All @@ -29,7 +28,9 @@ def tearDown(self):
self.superuser.delete()

def test_html_rendering(self):
request_url = self.page.get_absolute_url(self.language) + "?toolbar_off=true"
request_url = (
self.page.get_absolute_url(self.language) + "?toolbar_off=true"
)
snippet = Snippet.objects.create(
name="plugin_snippet",
html="<p>Hello World</p>",
Expand All @@ -52,7 +53,9 @@ def test_html_rendering(self):
self.assertIn(b"<p>Hello World</p>", response.content)

def test_failing_html_rendering(self):
request_url = self.page.get_absolute_url(self.language) + "?toolbar_off=true"
request_url = (
self.page.get_absolute_url(self.language) + "?toolbar_off=true"
)
snippet = Snippet.objects.create(
name="plugin_snippet",
html="{% import weirdness %}",
Expand All @@ -70,10 +73,14 @@ def test_failing_html_rendering(self):
response = self.client.get(request_url)

self.assertContains(response, "Invalid block tag on line 1")
self.assertContains(response, "Did you forget to register or load this tag?")
self.assertContains(
response, "Did you forget to register or load this tag?"
)

def test_template_rendering(self):
request_url = self.page.get_absolute_url(self.language) + "?toolbar_off=true"
request_url = (
self.page.get_absolute_url(self.language) + "?toolbar_off=true"
)
template = "snippet.html"
snippet = Snippet.objects.create(
name="plugin_snippet",
Expand All @@ -94,13 +101,22 @@ def test_template_rendering(self):
with self.login_user_context(self.superuser):
response = self.client.get(request_url)

self.assertNotIn("Template {} does not exist".format(template).encode(), response.content)
self.assertNotIn(b"context must be a dict rather than Context", response.content)
self.assertNotIn(b"context must be a dict rather than PluginContext", response.content)
self.assertNotIn(
f"Template {template} does not exist".encode(), response.content
)
self.assertNotIn(
b"context must be a dict rather than Context", response.content
)
self.assertNotIn(
b"context must be a dict rather than PluginContext",
response.content,
)
self.assertContains(response, "<p>Hello World Template</p>")

def test_failing_template_rendering(self):
request_url = self.page.get_absolute_url(self.language) + "?toolbar_off=true"
request_url = (
self.page.get_absolute_url(self.language) + "?toolbar_off=true"
)
template = "some_template"
snippet = Snippet.objects.create(
name="plugin_snippet",
Expand Down
36 changes: 15 additions & 21 deletions tests/test_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class SnippetTemplateTagTestCase(TestCase):

def test_html_rendered(self):
snippet = Snippet.objects.create(
name="test snippet",
Expand All @@ -20,17 +19,15 @@ def test_html_rendered(self):

context = Context({"title": "world"})
template_to_render = Template(
'{% load snippet_tags %}'
'{% snippet_fragment "test_snippet" %}'
"{% load snippet_tags %}" '{% snippet_fragment "test_snippet" %}'
)
rendered_template = template_to_render.render(context)
self.assertInHTML('<p>hello world</p>', rendered_template)
self.assertInHTML("<p>hello world</p>", rendered_template)

# test html errors
context = Context({"title": "world"})
template_to_render = Template(
'{% load snippet_tags %}'
'{% snippet_fragment "test_snippet_2" %}'
"{% load snippet_tags %}" '{% snippet_fragment "test_snippet_2" %}'
)
with self.assertRaises(ObjectDoesNotExist):
# Snippet matching query does not exist.
Expand All @@ -50,29 +47,27 @@ def test_template_rendered(self):
# use a string to identify
context = Context({})
template_to_render = Template(
'{% load snippet_tags %}'
'{% snippet_fragment "test_snippet" %}'
"{% load snippet_tags %}" '{% snippet_fragment "test_snippet" %}'
)
rendered_template = template_to_render.render(context)
self.assertInHTML('<p>Hello World Template</p>', rendered_template)
self.assertInHTML("<p>Hello World Template</p>", rendered_template)

# use an id to identify
context = Context({})
template_to_render = Template(
'{% load snippet_tags %}'
'{% snippet_fragment 1 %}'
"{% load snippet_tags %}" "{% snippet_fragment 1 %}"
)
rendered_template = template_to_render.render(context)
self.assertInHTML('<p>Hello World Template</p>', rendered_template)
self.assertInHTML("<p>Hello World Template</p>", rendered_template)

# tests "or" functionality
context = Context({})
template_to_render = Template(
'{% load snippet_tags %}'
"{% load snippet_tags %}"
'{% snippet_fragment "test_snippet_1" or %}<p>hello world</p>{% endsnippet_fragment %}'
)
rendered_template = template_to_render.render(context)
self.assertInHTML('<p>hello world</p>', rendered_template)
self.assertInHTML("<p>hello world</p>", rendered_template)

def test_template_errors(self):
template = "does_not_exist.html"
Expand All @@ -87,16 +82,16 @@ def test_template_errors(self):

context = Context({})
template_to_render = Template(
'{% load snippet_tags %}'
'{% snippet_fragment "test_snippet" %}'
"{% load snippet_tags %}" '{% snippet_fragment "test_snippet" %}'
)
rendered_template = template_to_render.render(context)
self.assertIn('Template does_not_exist.html does not exist.', rendered_template)
self.assertIn(
"Template does_not_exist.html does not exist.", rendered_template
)

context = Context({})
template_to_render = Template(
'{% load snippet_tags %}'
'{% snippet_fragment "test_snippet_1" %}'
"{% load snippet_tags %}" '{% snippet_fragment "test_snippet_1" %}'
)
with self.assertRaises(ObjectDoesNotExist):
# Snippet object does not exist
Expand All @@ -106,6 +101,5 @@ def test_template_errors(self):
with self.assertRaises(TemplateSyntaxError):
# You need to specify at least a "snippet" ID, slug or instance
template_to_render = Template(
'{% load snippet_tags %}'
'{% snippet_fragment %}'
"{% load snippet_tags %}" "{% snippet_fragment %}"
)

0 comments on commit 5ff1bac

Please sign in to comment.