From 300819d0291398fa8dbe72ce5e0183d11da95f2a Mon Sep 17 00:00:00 2001 From: Andrew Kos Date: Fri, 26 Aug 2016 12:44:58 -0500 Subject: [PATCH 1/2] Allow super feature child dates to be set for any parent publish date (#302) * update testing documentation * allow child dates to be set when parent has any publish date --- README.md | 15 ++++++--------- bulbs/super_features/views.py | 2 +- tests/super_features/test_views.py | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index aea95adb..d30b5d16 100644 --- a/README.md +++ b/README.md @@ -19,15 +19,12 @@ pip install "file://$(pwd)#egg=django-bulbs[dev]" ## Running Tests -1. Clone [django-elastimorphic](https://github.com/theonion/django-elastimorphic) into a sibiling directory -2. Install dev requirements -```bash -pip install -e ".[dev]" -``` -3. Run tests -```bash -py.test tests/ -``` +1. Clone, setup, and start [onion-services](https://github.com/theonion/onion-services/blob/master/README.md). +2. Run `./scripts/init_db` +3. Run `./scripts/test` + +A relative path to a folder or file can be given to `./scripts/test` to run +only a specific subset of tests. ## Building Docs ```bash diff --git a/bulbs/super_features/views.py b/bulbs/super_features/views.py index 0e152144..0396e928 100644 --- a/bulbs/super_features/views.py +++ b/bulbs/super_features/views.py @@ -64,7 +64,7 @@ class SetChildrenDatesViewSet(views.APIView): def put(self, request, pk): parent = get_object_or_404(SUPERFEATURE_MODEL, pk=pk) - if not parent.is_published: + if not parent.published: return Response( {'detail': 'Parent publish date is not set'}, status=status.HTTP_400_BAD_REQUEST diff --git a/tests/super_features/test_views.py b/tests/super_features/test_views.py index 0e075089..07711db8 100644 --- a/tests/super_features/test_views.py +++ b/tests/super_features/test_views.py @@ -1,4 +1,5 @@ from collections import OrderedDict +from datetime import timedelta from django.core.urlresolvers import reverse from django.utils import timezone @@ -125,6 +126,24 @@ def test_parent_set_child_dates(self): child = BaseSuperFeature.objects.get(id=self.child.id) self.assertEqual(self.parent.published, child.published) + def test_parent_set_child_dates_in_future(self): + """Should be able to set publish dates for children even if parent + publish date is in the future.""" + + self.parent.published = timezone.now() + timedelta(days=1) + self.parent.save() + + url = reverse( + 'super-feature-set-children-dates', + kwargs={'pk': self.parent.pk} + ) + resp = self.api_client.put(url) + + self.assertEqual(resp.status_code, 200) + + child = BaseSuperFeature.objects.get(id=self.child.id) + self.assertEqual(self.parent.published, child.published) + def test_relations_ordering(self): child2 = BaseSuperFeature.objects.create( title="Guide to Bats", From 5700d5b8ac3332003cef03df5b8da1950cd25699 Mon Sep 17 00:00:00 2001 From: Andrew Kos Date: Fri, 26 Aug 2016 12:46:12 -0500 Subject: [PATCH 2/2] version 3.12.4 --- bulbs/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bulbs/__init__.py b/bulbs/__init__.py index 10cae7f6..0bf8b276 100644 --- a/bulbs/__init__.py +++ b/bulbs/__init__.py @@ -1 +1 @@ -__version__ = "3.12.3" +__version__ = "3.12.4"