Esempio n. 1
0
    def test_admin_timeline_prunes_user_output(self):
        """multiple users in timeline is confusing."""
        admin = self.User.objects.create(username="******", email="*****@*****.**")
        admin.is_staff = True
        admin.is_superuser = True
        admin.save()

        # create a drip campaign that will surely give us duplicates.
        model_drip = Drip.objects.create(
            name="A Custom Week Ago", subject_template="HELLO {{ user.username }}", body_html_template="KETTEHS ROCK!"
        )
        QuerySetRule.objects.create(
            drip=model_drip,
            field_name="date_joined",
            lookup_type="gte",
            field_value=(timezone.now() - timedelta(days=1)).isoformat(),
        )

        # then get it's admin view.
        rf = RequestFactory()
        timeline_url = reverse(
            "admin:drip_timeline", kwargs={"drip_id": model_drip.id, "into_past": 3, "into_future": 3}
        )

        request = rf.get(timeline_url)
        request.user = admin

        match = resolve(timeline_url)

        response = match.func(request, *match.args, **match.kwargs)

        # check that our admin (not excluded from test) is shown once.
        self.assertEqual(unicode(response.content).count(admin.email), 1)
    def test_admin_timeline_prunes_user_output(self):
        """
        multiple users in timeline is confusing.
        """
        admin = self.User.objects.create(
            username='******', email='*****@*****.**')
        admin.is_staff = True
        admin.is_superuser = True
        admin.save()

        # create a drip campaign that will surely give us duplicates.
        model_drip = Drip.objects.create(
            name='A Custom Week Ago',
            subject_template='HELLO {{ user.username }}',
            body_html_template='KETTEHS ROCK!'
        )
        QuerySetRule.objects.create(
            drip=model_drip,
            field_name='date_joined',
            lookup_type='gte',
            field_value=(
                timezone.now() - timedelta(days=1)
            ).strftime('%Y-%m-%d 00:00:00'),
        )

        # then get it's admin view.
        rf = RequestFactory()
        timeline_url = reverse(
            'admin:drip_timeline',
            kwargs={
                'drip_id': model_drip.id,
                'into_past': 3,
                'into_future': 3,
            }
        )

        request = rf.get(timeline_url)
        request.user = admin

        match = resolve(timeline_url)

        response = match.func(request, *match.args, **match.kwargs)

        # check that our admin (not excluded from test) is shown once.
        self.assertEqual(unicode(response.content).count(admin.email), 1)
Esempio n. 3
0
    def test_admin_timeline_prunes_user_output(self):
        """multiple users in timeline is confusing."""
        admin = self.User.objects.create(username='******', email='*****@*****.**')
        admin.is_staff=True
        admin.is_superuser=True
        admin.save()

        # create a drip campaign that will surely give us duplicates.
        model_drip = Drip.objects.create(
            name='A Custom Week Ago',
            subject_template='HELLO {{ user.username }}',
            body_html_template='KETTEHS ROCK!'
        )
        QuerySetRule.objects.create(
            drip=model_drip,
            field_name='date_joined',
            lookup_type='gte',
            field_value=(timezone.now() - timedelta(days=1)).strftime('%Y-%m-%d 00:00:00')
        )

        # then get it's admin view.
        rf = RequestFactory()
        timeline_url = reverse('admin:drip_timeline', kwargs={
                                    'drip_id': model_drip.id,
                                    'into_past': 3,
                                    'into_future': 3})

        request = rf.get(timeline_url)
        request.user = admin

        match = resolve(timeline_url)

        response = match.func(request, *match.args, **match.kwargs)

        # check that our admin (not excluded from test) is shown once.
        self.assertEqual(unicode(response.content).count(admin.email), 1)