Beispiel #1
0
 def test_message_with_url_is_link(self):
     m = Message(message="Go to http://bit.ly/sample-demo", is_global=True,
                 is_active=True, url="/")
     m.save()
     ok_('Go to <a href="http://bit.ly/sample-demo">'
         'http://bit.ly/sample-demo</a>' in
         soapbox_messages(get_soapbox_messages("/")))
Beispiel #2
0
 def test_message_with_url_is_link(self):
     m = Message(message="Go to http://bit.ly/sample-demo", is_global=True,
                 is_active=True, url="/")
     m.save()
     ok_('Go to <a href="http://bit.ly/sample-demo">'
         'http://bit.ly/sample-demo</a>' in
         soapbox_messages(get_soapbox_messages("/")))
Beispiel #3
0
 def test_message_with_url_is_link(self):
     m = Message(message='Go to http://bit.ly/sample-demo',
                 is_global=True,
                 is_active=True,
                 url='/')
     m.save()
     assert 'Go to <a href="http://bit.ly/sample-demo" rel="noopener">' \
            'http://bit.ly/sample-demo</a>' in soapbox_messages(get_soapbox_messages('/'))
Beispiel #4
0
 def test_subsection_message(self):
     m = Message(message='Search down', is_global=False, is_active=True,
                 url='/search')
     m.save()
     eq_(0, len(get_soapbox_messages('/')))
     eq_(0, len(get_soapbox_messages('/docs')))
     eq_(0, len(get_soapbox_messages('/en-US/docs')))
     eq_(m.message, get_soapbox_messages('/en-US/search')[0].message)
     eq_(m.message, get_soapbox_messages('/de/search')[0].message)
Beispiel #5
0
 def test_subsection_message(self):
     m = Message(message='Search down', is_global=False, is_active=True,
                 url='/search')
     m.save()
     assert 0 == len(get_soapbox_messages('/'))
     assert 0 == len(get_soapbox_messages('/docs'))
     assert 0 == len(get_soapbox_messages('/en-US/docs'))
     assert m.message == get_soapbox_messages('/en-US/search')[0].message
     assert m.message == get_soapbox_messages('/de/search')[0].message
Beispiel #6
0
    def test_inactive(self):
        m = Message(message="Search", is_global=False, is_active=False, url="/search/")
        m.save()

        url = reverse("home")
        r = self.client.get(url, follow=True)
        assert 200 == r.status_code

        doc = pq(r.content)
        assert not doc.find("div.global-notice")
Beispiel #7
0
 def test_subsection_message(self):
     m = Message(message="Derby", is_global=False, is_active=True,
                 url="/demos/devderby")
     m.save()
     eq_(0, len(get_soapbox_messages("/")))
     eq_(0, len(get_soapbox_messages("/demos")))
     eq_(0, len(get_soapbox_messages("/en-US/demos")))
     eq_(m.message, get_soapbox_messages(
         "/en-US/demos/devderby")[0].message)
     eq_(m.message, get_soapbox_messages("/de/demos/devderby")[0].message)
Beispiel #8
0
    def test_global_home(self):
        m = Message(message='Global', is_global=True, is_active=True, url='/')
        m.save()

        url = reverse('home')
        r = self.client.get(url, follow=True)
        assert 200 == r.status_code

        doc = pq(r.content)
        assert m.message == doc.find('div.global-notice').text()
Beispiel #9
0
    def test_global_home(self):
        m = Message(message='Global', is_global=True, is_active=True, url='/')
        m.save()

        url = reverse('home')
        r = self.client.get(url, follow=True)
        eq_(200, r.status_code)

        doc = pq(r.content)
        eq_(m.message, doc.find('div.global-notice').text())
Beispiel #10
0
 def test_subsection_message(self):
     m = Message(message="Derby", is_global=False, is_active=True,
                 url="/demos/devderby")
     m.save()
     eq_(0, len(get_soapbox_messages("/")))
     eq_(0, len(get_soapbox_messages("/demos")))
     eq_(0, len(get_soapbox_messages("/en-US/demos")))
     eq_(m.message, get_soapbox_messages(
         "/en-US/demos/devderby")[0].message)
     eq_(m.message, get_soapbox_messages("/de/demos/devderby")[0].message)
Beispiel #11
0
    def test_inactive(self):
        m = Message(message="Demos", is_global=False, is_active=False, url="/demos/")
        m.save()

        url = reverse("demos")
        r = self.client.get(url, follow=True)
        eq_(200, r.status_code)

        doc = pq(r.content)
        eq_([], doc.find("div.global-notice"))
Beispiel #12
0
 def test_subsection_message(self):
     m = Message(message="Search down",
                 is_global=False,
                 is_active=True,
                 url="/search")
     m.save()
     assert 0 == len(get_soapbox_messages("/"))
     assert 0 == len(get_soapbox_messages("/docs"))
     assert 0 == len(get_soapbox_messages("/en-US/docs"))
     assert m.message == get_soapbox_messages("/en-US/search")[0].message
     assert m.message == get_soapbox_messages("/de/search")[0].message
Beispiel #13
0
    def test_inactive(self):
        m = Message(message='Search', is_global=False, is_active=False,
                    url='/search/')
        m.save()

        url = reverse('search')
        r = self.client.get(url, follow=True)
        eq_(200, r.status_code)

        doc = pq(r.content)
        eq_([], doc.find('div.global-notice'))
Beispiel #14
0
    def test_inactive(self):
        m = Message(message='Search', is_global=False, is_active=False,
                    url='/search/')
        m.save()

        url = reverse('search')
        r = self.client.get(url, follow=True)
        assert 200 == r.status_code

        doc = pq(r.content)
        assert not doc.find('div.global-notice')
Beispiel #15
0
 def test_message_with_url_is_link(self):
     m = Message(
         message="Go to http://bit.ly/sample-demo",
         is_global=True,
         is_active=True,
         url="/",
     )
     m.save()
     assert ('Go to <a href="http://bit.ly/sample-demo" rel="noopener">'
             "http://bit.ly/sample-demo</a>"
             in soapbox_messages(get_soapbox_messages("/")))
Beispiel #16
0
    def test_inactive(self):
        m = Message(message="Events", is_global=False, is_active=False,
                    url="/events/")
        m.save()

        url = reverse('events')
        r = self.client.get(url, follow=True)
        eq_(200, r.status_code)

        doc = pq(r.content)
        eq_([], doc.find('div.global-notice'))
    def test_where_required(self):
        """
        A Message instance must either be global or specify a URL
        prefix to match.

        """
        m = Message(
            message="Invalid message that's neither global nor local.",
            is_global=False,
            is_active=True,
        )
        with self.assertRaises(ValidationError, msg=WHERE_REQUIRED):
            m.clean()
Beispiel #18
0
    def test_global_home(self):
        m = Message(message="Global", is_global=True, is_active=True, url="/")
        m.save()

        url = reverse('home')
        r = self.client.get(url, follow=True)
        eq_(200, r.status_code)

        doc = pq(r.content)
        eq_(m.message, doc.find('div.global-notice').text())

        url = reverse('events')
        r = self.client.get(url, follow=True)
        eq_(200, r.status_code)

        doc = pq(r.content)
        eq_(m.message, doc.find('div.global-notice').text())
Beispiel #19
0
    def test_subsection(self):
        m = Message(message="Events", is_global=False, is_active=True, url="/events/")
        m.save()

        url = reverse("events")
        r = self.client.get(url, follow=True)
        eq_(200, r.status_code)

        doc = pq(r.content)
        eq_(m.message, doc.find("div.global-notice").text())

        url = reverse("home")
        r = self.client.get(url, follow=True)
        eq_(200, r.status_code)

        doc = pq(r.content)
        eq_([], doc.find("div.global-notice"))
Beispiel #20
0
    def test_global_home(self):
        m = Message(message="Global", is_global=True, is_active=True, url="/")
        m.save()

        url = reverse("home")
        r = self.client.get(url, follow=True)
        eq_(200, r.status_code)

        doc = pq(r.content)
        eq_(m.message, doc.find("div.global-notice").text())

        url = reverse("demos")
        r = self.client.get(url, follow=True)
        eq_(200, r.status_code)

        doc = pq(r.content)
        eq_(m.message, doc.find("div.global-notice").text())
Beispiel #21
0
    def test_subsection(self):
        m = Message(message='Search', is_global=False, is_active=True,
                    url='/search/')
        m.save()

        url = reverse('search')
        r = self.client.get(url, follow=True)
        eq_(200, r.status_code)

        doc = pq(r.content)
        eq_(m.message, doc.find('div.global-notice').text())

        url = reverse('home')
        r = self.client.get(url, follow=True)
        eq_(200, r.status_code)

        doc = pq(r.content)
        eq_([], doc.find('div.global-notice'))
    def test_global_or_local(self):
        """
        Message instances can be global, or appear on selected pages,
        but not both.

        """
        m = Message(
            message="Invalid message that's both global and local.",
            is_global=True,
            is_active=True,
            url="/foo/",
        )
        with self.assertRaises(ValidationError, msg=GLOBAL_OR_LOCAL):
            m.clean()

        m = Message(
            message="Valid message that's both global and has an empty URL.",
            is_global=True,
            is_active=True,
            url="",
        )
        m.clean()
Beispiel #23
0
 def test_global_message(self):
     m = Message(message="Global", is_global=True, is_active=True, url="/")
     m.save()
     eq_(m.message, get_soapbox_messages("/")[0].message)
     eq_(m.message, get_soapbox_messages("/en-US/")[0].message)
     eq_(m.message, get_soapbox_messages("/fr/demos/")[0].message)
Beispiel #24
0
 def test_global_message(self):
     m = Message(message="Global", is_global=True, is_active=True, url="/")
     m.save()
     assert m.message == get_soapbox_messages("/")[0].message
     assert m.message == get_soapbox_messages("/en-US/")[0].message
Beispiel #25
0
 def test_global_message(self):
     m = Message(message='Global', is_global=True, is_active=True, url='/')
     m.save()
     assert m.message == get_soapbox_messages('/')[0].message
     assert m.message == get_soapbox_messages('/en-US/')[0].message
Beispiel #26
0
 def test_global_message(self):
     m = Message(message="Global", is_global=True, is_active=True, url="/")
     m.save()
     eq_(m.message, get_soapbox_messages("/")[0].message)
     eq_(m.message, get_soapbox_messages("/en-US/")[0].message)
     eq_(m.message, get_soapbox_messages("/fr/demos/")[0].message)
Beispiel #27
0
 def test_global_message(self):
     m = Message(message='Global', is_global=True, is_active=True, url='/')
     m.save()
     assert m.message == get_soapbox_messages('/')[0].message
     assert m.message == get_soapbox_messages('/en-US/')[0].message
Beispiel #28
0
 def test_message_with_url_is_link(self):
     m = Message(message='Go to http://bit.ly/sample-demo', is_global=True,
                 is_active=True, url='/')
     m.save()
     assert 'Go to <a href="http://bit.ly/sample-demo" rel="noopener">' \
            'http://bit.ly/sample-demo</a>' in soapbox_messages(get_soapbox_messages('/'))