Exemplo n.º 1
0
    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()
Exemplo n.º 2
0
    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()