Skip to content

Commit

Permalink
Update dependencies, specially Django to v5 (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
danirus authored Jan 30, 2024
1 parent f601f3b commit c993329
Show file tree
Hide file tree
Showing 22 changed files with 65 additions and 502 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/ci-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Python setup
uses: actions/setup-python@v2
with:
python-version: '3.10'
python-version: '3.12'
- name: Install test dependencies
run: pip install -r requirements-tests.txt
- name: Check syntax with black
Expand All @@ -23,28 +23,28 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
django: ["3.2", "4.0", "4.1"]
django: ["4.1", "4.2", "5.0"]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Python setup
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.12'
- name: Install tox and django
run: pip install tox "django==${{ matrix.django }}"
- name: Run unit tests
run: tox -e py3.10-django${{ matrix.django }}
run: tox -e py3.12-django${{ matrix.django }}

javascript:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: '14'
node-version: '18'
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
Expand Down
24 changes: 1 addition & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.DEFAULT_GOAL := help

.PHONY: coverage help tox syntax-check syntax-format pip-compile pip-install
.PHONY: coverage help

coverage: ## Run tests with coverage.
coverage erase
Expand All @@ -9,28 +9,6 @@ coverage: ## Run tests with coverage.
coverage report -m
@sh ./ccsvg.sh ||:

syntax-check: ## Check syntax code (isort and black).
black --check django_comments_ink

syntax-format: ## Format syntax code (isort and black).
black django_comments_ink

tox: ## Run tox.
python -m tox

pip-compile: ## Generate requirements.txt and requirements-dev.txt files.
python -c "import piptools" > /dev/null 2>&1 || pip install pip-tools
pip-compile --generate-hashes --allow-unsafe \
--output-file requirements.txt requirements.in
pip-compile --allow-unsafe \
--output-file requirements-tests.txt requirements-tests.in
pip-compile --generate-hashes --allow-unsafe \
--output-file requirements-dev.txt requirements-dev.in

pip-install: ## Install dependencies listed in requirements-dev.txt.
pip install -r requirements.txt
pip install -r requirements-dev.txt

help: ## Show help message
@IFS=$$'\n' ; \
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \
Expand Down
6 changes: 3 additions & 3 deletions coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion django_comments_ink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def get_form_target():
return reverse("comments-ink-post")


VERSION = (0, 3, 0, "f", 0) # following PEP 440
VERSION = (0, 4, 0, "f", 0) # following PEP 440


def get_version():
Expand Down
4 changes: 2 additions & 2 deletions django_comments_ink/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def validate(self, data):
sender=target.__class__, comment=target, request=self.request
)

for (receiver, response) in responses:
for receiver, response in responses:
if response is True:
# A positive response indicates that the POST request
# must be trusted. So inject the CommentSecurityForm values
Expand Down Expand Up @@ -183,7 +183,7 @@ def save(self):
responses = comment_will_be_posted.send(
sender=TmpInkComment, comment=resp["comment"], request=self.request
)
for (receiver, response) in responses:
for receiver, response in responses:
if response is False:
resp["code"] = 403 # Rejected.
return resp
Expand Down
1 change: 1 addition & 0 deletions django_comments_ink/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ def on_comment_vote_deleted(sender, instance, using, **kwargs):

post_delete.connect(on_comment_vote_deleted, sender=CommentVote)


# ----------------------------------------------------------------------
class BlackListedDomain(models.Model):
"""
Expand Down
1 change: 1 addition & 0 deletions django_comments_ink/paginator.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
per_page + orphans, so the 2nd page will contain 18 comments.
"""

import logging

from django.apps import apps
Expand Down
1 change: 1 addition & 0 deletions django_comments_ink/signals.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Signals relating to django-comments-ink.
"""

from django.dispatch import Signal


Expand Down
1 change: 1 addition & 0 deletions django_comments_ink/signed.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
There are 65 url-safe characters: the 64 used by url-safe base64 and the '.'.
These functions make use of all of them.
"""

from __future__ import unicode_literals

import base64
Expand Down
10 changes: 0 additions & 10 deletions django_comments_ink/tests/pytest_fixtures/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from django_comments_ink.tests.models import Article, Diary


@pytest.mark.django_db
@pytest.fixture
def an_article():
"""Creates an article that can receive comments."""
Expand All @@ -28,7 +27,6 @@ def an_article():
article.delete()


@pytest.mark.django_db
@pytest.fixture
def a_diary_entry():
"""Creates a diary entry that can receive comments."""
Expand All @@ -37,7 +35,6 @@ def a_diary_entry():
entry.delete()


@pytest.mark.django_db
@pytest.fixture
def an_articles_comment(an_article):
"""Send a comment to the article."""
Expand All @@ -55,7 +52,6 @@ def an_articles_comment(an_article):
comment.delete()


@pytest.mark.django_db
@pytest.fixture
def an_user():
"""Add a user to the DB."""
Expand All @@ -66,7 +62,6 @@ def an_user():
user.delete()


@pytest.mark.django_db
@pytest.fixture
def an_user_2():
"""Add a user2 to the DB."""
Expand All @@ -81,7 +76,6 @@ def an_user_2():
user2.delete()


@pytest.mark.django_db
@pytest.fixture
def a_comments_reaction(an_articles_comment, an_user):
"""Send a comment reaction to a comment."""
Expand All @@ -95,7 +89,6 @@ def a_comments_reaction(an_articles_comment, an_user):
cmr.delete()


@pytest.mark.django_db
@pytest.fixture
def a_comments_reaction_2(an_user_2, a_comments_reaction):
"""Send another comment reaction to a comment."""
Expand All @@ -105,7 +98,6 @@ def a_comments_reaction_2(an_user_2, a_comments_reaction):
return a_comments_reaction


@pytest.mark.django_db
@pytest.fixture
def a_comments_flag(an_articles_comment, an_user):
"""Send a CommentFlag.SUGGEST_REMOVAL flag to a comment."""
Expand All @@ -118,7 +110,6 @@ def a_comments_flag(an_articles_comment, an_user):
comment_flag.delete()


@pytest.mark.django_db
@pytest.fixture
def an_object_reaction(a_diary_entry, an_user):
"""Send an object reaction to a diary entry."""
Expand All @@ -138,7 +129,6 @@ def an_object_reaction(a_diary_entry, an_user):
objr.delete()


@pytest.mark.django_db
@pytest.fixture
def an_object_reaction_2(an_user_2, an_object_reaction):
"""Send another object reaction to a diary entry."""
Expand Down
1 change: 1 addition & 0 deletions django_comments_ink/tests/test_signed.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Tests borrowed from Simon Willison's Django-OpenID project:
* https://github.com/simonw/django-openid
"""

import pytest
from django.conf import settings
from django_comments_ink import signed
Expand Down
30 changes: 20 additions & 10 deletions django_comments_ink/tests/test_templatetags.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import collections
from datetime import datetime
import importlib
import json
import re
from unittest.mock import patch

import django
import pytest
from django.contrib.auth.models import AnonymousUser
from django.contrib.contenttypes.models import ContentType
Expand All @@ -26,7 +26,6 @@
from django_comments_ink.conf import settings
from django_comments_ink.models import (
InkComment,
ObjectReaction,
publish_or_withhold_on_pre_save,
)
from django_comments_ink.templatetags import comments_ink
Expand Down Expand Up @@ -1343,14 +1342,25 @@ def check_form_fields_in_output(output):
assert match != None

# Check field 'email':
match = re.search(
(
r'<input type="text" name="email" placeholder="mail address"'
r' class="form-control" required id="id_email">'
),
output,
)
assert match != None
if django.VERSION[0] == 5:
match = re.search(
(
r'<input type="text" name="email" placeholder="mail address"'
r' class="form-control" required'
r' aria-describedby="id_email_helptext" id="id_email">'
),
output,
)
assert match != None
else:
match = re.search(
(
r'<input type="text" name="email" placeholder="mail address"'
r' class="form-control" required id="id_email">'
),
output,
)
assert match != None

# Check field 'url':
match = re.search(
Expand Down
4 changes: 2 additions & 2 deletions django_comments_ink/views/commenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def confirm(
sender=TmpInkComment, comment=tmp_comment, request=request
)
# Check whether a signal receiver decides to discard the comment.
for (receiver, response) in responses:
for receiver, response in responses:
if response is False:
return render(request, template_discarded, {"comment": tmp_comment})

Expand Down Expand Up @@ -420,7 +420,7 @@ def create_comment(self, form):
sender=comment.__class__, comment=comment, request=self.request
)

for (receiver, response) in responses:
for receiver, response in responses:
if response is False:
msg = (
"comment_will_be_posted receiver %r killed the comment"
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=60.2.0", "wheel"]
requires = ["setuptools>=69.0.3", "wheel"]
build-backend = "setuptools.build_meta"

[tool.coverage.report]
Expand All @@ -12,7 +12,6 @@ exclude_lines = [

[tool.black]
line-length = 80
extend-exclude = '''pqenv|psenv'''

[tool.pytest]
addopts = "--create-db"
Expand Down
9 changes: 0 additions & 9 deletions requirements-dev.in

This file was deleted.

Loading

0 comments on commit c993329

Please sign in to comment.