-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from vintasoftware/feat/django-v5
Add support for Django 4.2 and 5.0, and drop support for prior versions
- Loading branch information
Showing
22 changed files
with
373 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# https://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
end_of_line = lf | ||
|
||
[*.{json,html,md,yml,yaml}] | ||
indent_size = 2 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.ini] | ||
indent_style = tab | ||
|
||
[Makefile] | ||
indent_style = tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: tests | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
name: Test (Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }}) | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
django-version: ["4.2", "5.0"] | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements_test.txt | ||
- name: Run tests with coverage | ||
run: tox -- --keepdb --parallel | ||
env: | ||
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
# -*- coding: utf-8 | ||
__title__ = 'CeleryBeat Status' | ||
__version__ = '0.0.10' | ||
__author__ = 'Vinta Software' | ||
__license__ = 'MIT License' | ||
__copyright__ = 'Copyright 2017 Vinta Serviços e Soluções Tecnológicas Ltda' | ||
__title__ = "CeleryBeat Status" | ||
__version__ = "1.0.0" | ||
__author__ = "Vinta Software" | ||
__license__ = "MIT License" | ||
__copyright__ = "Copyright 2017 Vinta Serviços e Soluções Tecnológicas Ltda" | ||
|
||
# Version synonym | ||
VERSION = __version__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from django.contrib.admin.sites import AdminSite | ||
AdminSite.index_template = 'celerybeat_status/custom_admin/index.html' | ||
|
||
AdminSite.index_template = "celerybeat_status/custom_admin/index.html" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
|
||
class CeleryBeatStatusConfig(AppConfig): | ||
name = 'celerybeat_status' | ||
name = "celerybeat_status" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
celerybeat_status/templates/celerybeat_status/custom_admin/sidebar.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<div id="content-related"> | ||
{% include "admin/sidebar_widgets/statuscheck.html" %} | ||
{% include "admin/sidebar_widgets/actions.html" %} | ||
{% include "celerybeat_status/custom_admin/sidebar_widgets/statuscheck.html" %} | ||
{% include "celerybeat_status/custom_admin/sidebar_widgets/actions.html" %} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,33 @@ | ||
from django.utils import version as django_version | ||
from django.contrib.auth import get_user_model | ||
from django.urls import reverse | ||
|
||
from celerybeat_status.tests.utils import ( | ||
SuperuserBaseTestCase, TestRequiresSuperuser) | ||
from celerybeat_status.tests.utils import BaseTestCase, TestRequiresAuthenticatedUser | ||
|
||
if django_version.get_complete_version() < (2, 0, 0): | ||
from django.core.urlresolvers import reverse | ||
else: | ||
from django.urls import reverse | ||
User = get_user_model() | ||
|
||
|
||
class PeriodicTaskStatusListTests( | ||
TestRequiresSuperuser, SuperuserBaseTestCase): | ||
view_name = 'periodic-tasks-status' | ||
class PeriodicTasksStatusListViewTests(TestRequiresAuthenticatedUser, BaseTestCase): | ||
view_name = "celerybeat_status:periodic-tasks-status" | ||
|
||
def setUp(self): | ||
super(PeriodicTaskStatusListTests, self).setUp() | ||
super().setUp() | ||
self.view_url = reverse(self.view_name) | ||
|
||
def test_non_authenticated_user_is_redirected(self): | ||
response = self.client.get(self.view_url) | ||
self.assertRedirects(response, "/admin/login/?next=" + self.view_url) | ||
|
||
def test_regular_user_access_returns_forbidden(self): | ||
self.client.force_login(self.regular_user) | ||
response = self.client.get(self.view_url) | ||
self.assertEqual(response.status_code, 403) | ||
|
||
def test_staff_user_access_returns_forbidden(self): | ||
self.client.force_login(self.staff_user) | ||
response = self.client.get(self.view_url) | ||
self.assertEqual(response.status_code, 403) | ||
|
||
def test_superuser_access_returns_success(self): | ||
self.client.force_login(self.superuser) | ||
response = self.client.get(self.view_url) | ||
self.assertEqual(response.status_code, 200) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,38 @@ | ||
from django.test import TestCase, Client | ||
from django.contrib.auth import get_user_model | ||
from django.test import Client, TestCase | ||
|
||
User = get_user_model() | ||
|
||
|
||
class BaseTestCase(TestCase): | ||
|
||
def setUp(self): | ||
super(BaseTestCase, self).setUp() | ||
self.user_email = '[email protected]' | ||
self.user_password = 'the_password' | ||
self.user = User.objects.create_user( | ||
username='testuser', email=self.user_email, | ||
password=self.user_password) | ||
|
||
self.auth_client = Client() | ||
self.auth_client.force_login(self.user) | ||
|
||
|
||
class SuperuserBaseTestCase(BaseTestCase): | ||
|
||
def setUp(self): | ||
self.superuser_email = '[email protected]' | ||
self.superuser_password = 'the_password' | ||
self.superuser = User.objects.create_superuser( | ||
username='testsuperuser', | ||
email=self.superuser_email, | ||
password=self.superuser_password) | ||
|
||
self.super_client = Client() | ||
self.super_client.force_login(self.superuser) | ||
|
||
super(SuperuserBaseTestCase, self).setUp() | ||
super().setUp() | ||
self.regular_user = User.objects.create_user( | ||
username="regular", | ||
email="[email protected]", | ||
password="123", | ||
is_staff=False, | ||
is_superuser=False, | ||
) | ||
self.staff_user = User.objects.create_user( | ||
username="staff", | ||
email="[email protected]", | ||
password="123", | ||
is_staff=True, | ||
is_superuser=False, | ||
) | ||
self.superuser = User.objects.create_user( | ||
username="super", | ||
email="[email protected]", | ||
password="123", | ||
is_staff=True, | ||
is_superuser=True, | ||
) | ||
|
||
|
||
class TestRequiresAuthenticatedUser(object): | ||
|
||
def test_requires_authenticated_user(self): | ||
response = self.client.get(self.view_url) | ||
self.assertEqual(response.status_code, 302) | ||
|
||
|
||
class TestRequiresSuperuser(TestRequiresAuthenticatedUser): | ||
|
||
def test_requires_superuser(self): | ||
response = self.auth_client.get(self.view_url) | ||
self.assertEqual(response.status_code, 302) | ||
|
||
def test_superuser_get_request_success(self): | ||
response = self.super_client.get(self.view_url) | ||
self.assertEqual(response.status_code, 200) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
from django.conf.urls import url | ||
from django.urls import path | ||
|
||
from celerybeat_status.views import PeriodicTasksStatusListView | ||
|
||
app_name = "celerybeat_status" | ||
|
||
urlpatterns = [ | ||
url(r'^periodic-tasks/$', PeriodicTasksStatusListView.as_view(), | ||
name='periodic-tasks-status'), | ||
path( | ||
"periodic-tasks/", | ||
PeriodicTasksStatusListView.as_view(), | ||
name="periodic-tasks-status", | ||
), | ||
] |
Oops, something went wrong.