From 3df5d82bddd215999d67766c929f0d8c478327a4 Mon Sep 17 00:00:00 2001 From: Graham Ullrich Date: Wed, 24 Jan 2018 15:26:03 -0700 Subject: [PATCH 1/3] Fix reverse import --- CONTRIBUTING.md | 2 +- README.md | 5 +++++ pinax/calendars/adapters.py | 2 +- pinax/calendars/tests/tests.py | 19 ++++++++++++++++++- pinax/calendars/tests/urls.py | 5 +++++ setup.py | 2 +- 6 files changed, 31 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fae9907..e403a40 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -88,7 +88,7 @@ Here is an example of these rules applied: # second set of imports are Django imports with contrib in their own # group. - from django.core.urlresolvers import reverse + from django.urls import reverse from django.db import models from django.utils import timezone from django.utils.translation import ugettext_lazy as _ diff --git a/README.md b/README.md index ba0163c..8ed584a 100644 --- a/README.md +++ b/README.md @@ -268,6 +268,11 @@ day. ## Change Log +### 2.0.3 + +* fix `reverse` import +* add tests + ### 2.0.2 * Update requirements, add django>=1.11 diff --git a/pinax/calendars/adapters.py b/pinax/calendars/adapters.py index b4238eb..272fe41 100644 --- a/pinax/calendars/adapters.py +++ b/pinax/calendars/adapters.py @@ -1,6 +1,6 @@ from collections import defaultdict -from django.core.urlresolvers import reverse +from django.urls import reverse import pytz diff --git a/pinax/calendars/tests/tests.py b/pinax/calendars/tests/tests.py index 43a9365..34cc31a 100644 --- a/pinax/calendars/tests/tests.py +++ b/pinax/calendars/tests/tests.py @@ -1,6 +1,15 @@ +import datetime + from django.test import TestCase +from django.db import models +from django.urls import reverse + +from pinax.calendars.templatetags.pinax_calendars_tags import calendar, delta +from pinax.calendars.adapters import EventAdapter + -from pinax.calendars.templatetags.pinax_calendars_tags import delta +class EventModel(models.Model): + date = models.DateTimeField() class Tests(TestCase): @@ -20,3 +29,11 @@ def test_delta_next(self): """ self.assertEqual(delta(2016, 2, 1), (2016, 3)) self.assertEqual(delta(2015, 12, 1), (2016, 1)) + + def test_calendar_prev_next(self): + events = EventAdapter(EventModel.objects.none()) + + context = {} + cal = calendar(context, events, datetime.datetime(2017,2,1)) + self.assertEqual(cal["prev"], reverse("monthly", args=[2017, 1])) + self.assertEqual(cal["next"], reverse("monthly", args=[2017, 3])) diff --git a/pinax/calendars/tests/urls.py b/pinax/calendars/tests/urls.py index 1170d21..60693ed 100644 --- a/pinax/calendars/tests/urls.py +++ b/pinax/calendars/tests/urls.py @@ -1,2 +1,7 @@ +from django.conf.urls import url +from django.views.generic import View + urlpatterns = [ + url(r"^(?P\d{4})/(?P\d{1,2})/$", View.as_view(), name="monthly"), + url(r"^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/$", View.as_view(), name="daily"), ] diff --git a/setup.py b/setup.py index fa5bc5a..d34acd1 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import find_packages, setup -VERSION = "2.0.2" +VERSION = "2.0.3" LONG_DESCRIPTION = """ .. image:: http://pinaxproject.com/pinax-design/patches/pinax-calendars.svg :target: https://pypi.python.org/pypi/pinax-calendars/ From 2c312a2674903c0cba97a79c521decdea1fdf84e Mon Sep 17 00:00:00 2001 From: Graham Ullrich Date: Wed, 24 Jan 2018 15:27:59 -0700 Subject: [PATCH 2/3] plac8 --- pinax/calendars/tests/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pinax/calendars/tests/tests.py b/pinax/calendars/tests/tests.py index 34cc31a..8f86aca 100644 --- a/pinax/calendars/tests/tests.py +++ b/pinax/calendars/tests/tests.py @@ -34,6 +34,6 @@ def test_calendar_prev_next(self): events = EventAdapter(EventModel.objects.none()) context = {} - cal = calendar(context, events, datetime.datetime(2017,2,1)) + cal = calendar(context, events, datetime.datetime(2017, 2, 1)) self.assertEqual(cal["prev"], reverse("monthly", args=[2017, 1])) self.assertEqual(cal["next"], reverse("monthly", args=[2017, 3])) From 8dc1cf288a8f405929c4e2195dbbfa75956247c0 Mon Sep 17 00:00:00 2001 From: Graham Ullrich Date: Wed, 24 Jan 2018 15:29:35 -0700 Subject: [PATCH 3/3] plac8 --- pinax/calendars/tests/tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pinax/calendars/tests/tests.py b/pinax/calendars/tests/tests.py index 8f86aca..b3b81a1 100644 --- a/pinax/calendars/tests/tests.py +++ b/pinax/calendars/tests/tests.py @@ -1,11 +1,11 @@ import datetime -from django.test import TestCase from django.db import models +from django.test import TestCase from django.urls import reverse -from pinax.calendars.templatetags.pinax_calendars_tags import calendar, delta from pinax.calendars.adapters import EventAdapter +from pinax.calendars.templatetags.pinax_calendars_tags import calendar, delta class EventModel(models.Model):