def test_non_whitespace_command(self):
        """If a command has non-whitespace characters, the form should be valid."""
        project = ProjectFactory.create()
        shove_instance = ShoveInstanceFactory.create()
        project.shove_instances.add(shove_instance)

        form_data = {
            'command': '   whitespace but not blank   ',
            'shove_instances': [shove_instance.pk]
        }
        form = RunCommandForm(form_data, project=project)
        assert_true(form.is_valid())
    def test_whitespace_command(self):
        """If a command consists only of whitespace, the form should be invalid."""
        project = ProjectFactory.create()
        shove_instance = ShoveInstanceFactory.create()
        project.shove_instances.add(shove_instance)

        form = RunCommandForm({'command': '     ', 'shove_instances': [shove_instance.pk]},
                              project=project)
        assert_false(form.is_valid())

        form = RunCommandForm({'command': '\t\t', 'shove_instances': [shove_instance.pk]},
                              project=project)
        assert_false(form.is_valid())

        form = RunCommandForm({'command': '\n\n\n\n', 'shove_instances': [shove_instance.pk]},
                              project=project)
        assert_false(form.is_valid())