Ejemplo n.º 1
0
    def test_valid_topic_form(self):
        data = {
            "title": "Test Topic Title",
            "subtitle": "Test Topic Subtitle",
            "tags": "test,topic,tags",
            "text": "Test Topic Text",
        }
        form = TopicForm(data=data)

        self.assertTrue(form.is_valid())
Ejemplo n.º 2
0
    def test_invalid_topic_form_missing_text(self):
        """Test when text is missing"""
        data = {
            "title": "Test Topic Title",
            "subtitle": "Test Topic Subtitle",
            "tags": "test,topic,tags",
        }
        form = TopicForm(data=data)

        self.assertFalse(form.is_valid())
Ejemplo n.º 3
0
    def test_invalid_topic_form_missing_text(self):
        """ Test when text is missing """
        data = {
            'title': 'Test Topic Title',
            'subtitle': 'Test Topic Subtitle',
            'tags': 'test,topic,tags',
        }
        form = TopicForm(data=data)

        self.assertFalse(form.is_valid())
Ejemplo n.º 4
0
    def test_valid_topic_form_empty_tags(self):
        data = {
            'title': 'Test Topic Title',
            'subtitle': 'Test Topic Subtitle',
            'tags': '',
            'text': 'Test Topic Text'
        }
        form = TopicForm(data=data)

        self.assertTrue(form.is_valid())
Ejemplo n.º 5
0
    def test_invalid_topic_form_text_too_long(self):
        """Test when text runs over the length limit"""
        data = {
            "title": "Test Topic Title",
            "subtitle": "Test Topic Subtitle",
            "tags": "test,topic,tags",
            "text": text_too_long,
        }
        form = TopicForm(data=data)

        self.assertFalse(form.is_valid())
Ejemplo n.º 6
0
    def test_invalid_topic_form_empty_text(self):
        """ Test when text contains only whitespace """
        data = {
            "title": "Test Topic Title",
            "subtitle": "Test Topic Subtitle",
            "tags": "test,topic,tags",
            "text": " "
        }
        form = TopicForm(data=data)

        self.assertFalse(form.is_valid())
Ejemplo n.º 7
0
    def test_invalid_topic_form_text_too_long(self):
        """ Test when text runs over the length limit """
        data = {
            'title': 'Test Topic Title',
            'subtitle': 'Test Topic Subtitle',
            'tags': 'test,topic,tags',
            'text': text_too_long,
        }
        form = TopicForm(data=data)

        self.assertFalse(form.is_valid())
Ejemplo n.º 8
0
    def test_invalid_topic_form_empty_text(self):
        """ Test when text contains only whitespace """
        data = {
            'title': 'Test Topic Title',
            'subtitle': 'Test Topic Subtitle',
            'tags': 'test,topic,tags',
            'text': ' '
        }
        form = TopicForm(data=data)

        self.assertFalse(form.is_valid())