Esempio n. 1
0
 def test_facebook_question(self):
     question = SubmissionFactory(idea="Bogus & Broken")
     rsp = self.client.get(question.get_absolute_url())
     self.assertContains(
         rsp,
         '<meta property="og:url" content="%s"/>' % question.really_absolute_url()
     )
     self.assertContains(
         rsp,
         '<meta property="og:type" content="%s"/>' % 'website'
     )
     self.assertContains(
         rsp,
         '<meta property="og:title" content="%s"/>'
         % escape(settings.SITE_THEME['FACEBOOK_QUESTION_TITLE'])
     )
     self.assertContains(
         rsp,
         '<meta property="og:description" content="%s"/>'
         % escape(settings.SITE_THEME['FACEBOOK_QUESTION_DESCRIPTION']
                  .format(idea=question.idea))
     )
     self.assertContains(
         rsp,
         '<meta property="og:image" content="%s"/>' % settings.SITE_THEME['FACEBOOK_IMAGE']
     )
Esempio n. 2
0
 def test_twitter_question_card(self):
     question = SubmissionFactory(idea="Bogus & Broken")
     rsp = self.client.get(question.get_absolute_url())
     self.assertContains(rsp, '<meta name="twitter:card" content="summary_large_image">')
     self.assertContains(rsp,
                         '<meta name="twitter:title" content="%s">'
                         % escape(question.twitter_title()))
     self.assertContains(rsp,
                         '<meta name="twitter:description" content="%s">'
                         % escape(question.twitter_description()))
     self.assertContains(
         rsp,
         '<meta name="twitter:image" content="%s">' % settings.SITE_THEME['TWITTER_IMAGE']
     )
 def test_twitter_question_card(self):
     question = SubmissionFactory(idea="Bogus & Broken")
     rsp = self.client.get(question.get_absolute_url())
     self.assertContains(
         rsp, '<meta name="twitter:card" content="summary_large_image">')
     self.assertContains(
         rsp, '<meta name="twitter:title" content="%s">' %
         escape(question.twitter_title()))
     self.assertContains(
         rsp, '<meta name="twitter:description" content="%s">' %
         escape(question.twitter_description()))
     self.assertContains(
         rsp, '<meta name="twitter:image" content="%s">' %
         settings.SITE_THEME['TWITTER_IMAGE'])
class HeadlineTestTest(TestCase):
    def setUp(self):
        self.submission = SubmissionFactory()

    def test_headline_in_recent_events(self):
        mock_cache = mock.MagicMock()
        mock_cache.get.return_value = [self.submission]
        with mock.patch("opendebates.views.cache", new=mock_cache):
            rsp = self.client.get("/recent/")

        html = rsp.content.decode("UTF-8")
        self.assertIn(self.submission.headline, html)

    def test_headline_contributes_to_search(self):
        rsp = self.client.get(reverse("search_ideas") + "?q=%s" % self.submission.headline)
        html = rsp.content.decode("UTF-8")
        self.assertIn(self.submission.get_absolute_url(), html)

    def test_headline_contributes_to_merge(self):
        submission2 = SubmissionFactory()

        user = UserFactory(password="******", is_staff=True, is_superuser=True)
        VoterFactory(user=user, email=user.email)
        assert self.client.login(username=user.username, password="******")

        merge_url = reverse("moderation_merge")
        self.client.post(
            merge_url, data={"action": "merge", "to_remove": self.submission.id, "duplicate_of": submission2.id}
        )

        remaining = Submission.objects.get(id=submission2.id)

        self.assertIn(self.submission.headline, remaining.keywords)
 def test_facebook_question(self):
     question = SubmissionFactory(idea="Bogus & Broken")
     rsp = self.client.get(question.get_absolute_url())
     self.assertContains(
         rsp, '<meta property="og:url" content="%s"/>' %
         question.really_absolute_url())
     self.assertContains(
         rsp, '<meta property="og:type" content="%s"/>' % 'website')
     self.assertContains(
         rsp, '<meta property="og:title" content="%s"/>' %
         escape(settings.SITE_THEME['FACEBOOK_QUESTION_TITLE']))
     self.assertContains(
         rsp, '<meta property="og:description" content="%s"/>' %
         escape(settings.SITE_THEME['FACEBOOK_QUESTION_DESCRIPTION'].format(
             idea=question.idea)))
     self.assertContains(
         rsp, '<meta property="og:image" content="%s"/>' %
         settings.SITE_THEME['FACEBOOK_IMAGE'])
 def test_update_trending_scores(self):
     sub1 = SubmissionFactory()
     for i in range(30):
         VoteFactory(submission=sub1)
     self.assertEqual(0, sub1.random_id)
     self.assertEqual(0.0, sub1.score)
     update_trending_scores()
     sub1 = Submission.objects.get(pk=sub1.pk)
     self.assertNotEqual(0, sub1.random_id)
     self.assertGreater(sub1.score, 0.0)
class ThemeTests(TestCase):

    def setUp(self):
        self.idea = SubmissionFactory()

    @override_settings(SITE_THEME={
        'EMAIL_SUBJECT': 'THE EMAIL SUBJECT',
        'EMAIL_BODY': 'THE EMAIL BODY\nAND SECOND LINE',
    })
    def test_email_url(self):
        email_url = self.idea.email_url()
        fields = urlparse.parse_qs(urlparse.urlparse(email_url).query)
        self.assertTrue('subject' in fields, fields)
        self.assertEqual('THE EMAIL SUBJECT', fields['subject'][0], fields['subject'][0])
        self.assertEqual('THE EMAIL BODY\nAND SECOND LINE', fields['body'][0], fields['body'][0])
 def setUp(self):
     self.idea = SubmissionFactory(
         idea="How high is up?",
         headline="This is the headline",
         followup="This is the followup",
     )
     self.template_name = 'voted'
     EmailTemplateFactory(
         type=self.template_name,
         subject="{{ idea.headline }}",
         html="{{ idea.followup }}",
         text="{{ idea.idea }}",
         from_email="{{ idea.voter.email|safe }}",
         to_email="{{ idea.voter.email|safe }}",
     )
Esempio n. 9
0
class ThemeTests(TestCase):
    def setUp(self):
        self.idea = SubmissionFactory()

    @override_settings(
        SITE_THEME={
            'EMAIL_SUBJECT': 'THE EMAIL SUBJECT',
            'EMAIL_BODY': 'THE EMAIL BODY\nAND SECOND LINE',
        })
    def test_email_url(self):
        email_url = self.idea.email_url()
        fields = urlparse.parse_qs(urlparse.urlparse(email_url).query)
        self.assertTrue('subject' in fields, fields)
        self.assertEqual('THE EMAIL SUBJECT', fields['subject'][0],
                         fields['subject'][0])
        self.assertEqual('THE EMAIL BODY\nAND SECOND LINE', fields['body'][0],
                         fields['body'][0])
 def test_facebook_description(self):
     question = SubmissionFactory(idea="Bogus & Broken")
     self.assertEqual(
         settings.SITE_THEME['FACEBOOK_QUESTION_DESCRIPTION'].format(
             idea=question.idea), question.facebook_description())
Esempio n. 11
0
 def test_facebook_title(self):
     question = SubmissionFactory(idea="Bogus & Broken")
     self.assertEqual(
         settings.SITE_THEME['FACEBOOK_QUESTION_TITLE'].format(idea=question.idea),
         question.facebook_title()
     )
 def test_facebook_title(self):
     question = SubmissionFactory(idea="Bogus & Broken")
     self.assertEqual(
         settings.SITE_THEME['FACEBOOK_QUESTION_TITLE'].format(
             idea=question.idea), question.facebook_title())
 def setUp(self):
     self.idea = SubmissionFactory()
Esempio n. 14
0
 def test_facebook_description(self):
     question = SubmissionFactory(idea="Bogus & Broken")
     self.assertEqual(
         settings.SITE_THEME['FACEBOOK_QUESTION_DESCRIPTION'].format(idea=question.idea),
         question.facebook_description()
     )
Esempio n. 15
0
 def setUp(self):
     self.submission = SubmissionFactory()
Esempio n. 16
0
 def setUp(self):
     self.idea = SubmissionFactory()
Esempio n. 17
0
 def test_twitter_description(self):
     question = SubmissionFactory(idea="Bogus & Broken")
     self.assertEqual(
         settings.SITE_THEME['TWITTER_QUESTION_DESCRIPTION'].format(idea=question.idea),
         question.twitter_description()
     )
 def test_twitter_title(self):
     question = SubmissionFactory(idea="Bogus & Broken")
     self.assertEqual(
         settings.SITE_THEME['TWITTER_QUESTION_TITLE'].format(
             idea=question.idea), question.twitter_title())
 def setUp(self):
     self.idea = SubmissionFactory()
     self.ctx = {'idea': self.idea}
     self.type = 'template_name'
     EmailTemplateFactory(type=self.type)
 def test_twitter_description(self):
     question = SubmissionFactory(idea="Bogus & Broken")
     self.assertEqual(
         settings.SITE_THEME['TWITTER_QUESTION_DESCRIPTION'].format(
             idea=question.idea), question.twitter_description())
Esempio n. 21
0
 def test_twitter_title(self):
     question = SubmissionFactory(idea="Bogus & Broken")
     self.assertEqual(
         settings.SITE_THEME['TWITTER_QUESTION_TITLE'].format(idea=question.idea),
         question.twitter_title()
     )