Ejemplo n.º 1
0
class TestSettingsValidation(unittest.TestCase):

    def setUp(self):
        super(TestSettingsValidation, self).setUp()
        self.settings = ForwardSettingsFactory()

    def test_validate_url_bad(self):
        self.settings.url = 'badurl'
        with assert_raises(ValidationError):
            self.settings.save()

    def test_validate_url_good(self):
        self.settings.url = 'http://frozen.pizza.reviews/'
        try:
            self.settings.save()
        except ValidationError:
            assert 0

    def test_label_sanitary(self):
        self.settings.label = 'safe'
        try:
            self.settings.save()
        except ValidationError:
            assert False

    def test_label_unsanitary(self):
        self.settings.label = 'un<br />safe'
        with assert_raises(ValidationError):
            self.settings.save()
Ejemplo n.º 2
0
class TestSettingsValidation(unittest.TestCase):
    def setUp(self):
        super(TestSettingsValidation, self).setUp()
        self.settings = ForwardSettingsFactory()

    def test_validate_url_bad(self):
        self.settings.url = 'badurl'
        with assert_raises(ValidationError):
            self.settings.save()

    def test_validate_url_good(self):
        self.settings.url = 'http://frozen.pizza.reviews/'
        try:
            self.settings.save()
        except ValidationError:
            assert 0

    def test_label_sanitary(self):
        self.settings.label = 'safe'
        try:
            self.settings.save()
        except ValidationError:
            assert False

    def test_label_unsanitary(self):
        self.settings.label = 'un<br />safe'
        with assert_raises(ValidationError):
            self.settings.save()
Ejemplo n.º 3
0
    def test_settings_complete_true_no_redirect(self):
        """Regression test: Model can be complete when `redirect_bool` is False.

        """
        node_settings = ForwardSettingsFactory()
        assert_false(getattr(node_settings, 'redirect_bool', False))
        assert_true(utils.settings_complete(node_settings))
Ejemplo n.º 4
0
 def test_serialize_settings(self):
     node_settings = ForwardSettingsFactory()
     serialized = utils.serialize_settings(node_settings)
     assert_equal(serialized, {
         'url': node_settings.url,
         'label': node_settings.label,
     })
Ejemplo n.º 5
0
 def setUp(self):
     super(TestSettingsValidation, self).setUp()
     self.settings = ForwardSettingsFactory()
Ejemplo n.º 6
0
 def test_settings_complete_false(self):
     node_settings = ForwardSettingsFactory(url=None)
     assert_false(utils.settings_complete(node_settings))
Ejemplo n.º 7
0
 def test_settings_complete_true(self):
     node_settings = ForwardSettingsFactory()
     assert_true(utils.settings_complete(node_settings))
Ejemplo n.º 8
0
 def setUp(self):
     super(TestSettingsValidation, self).setUp()
     self.settings = ForwardSettingsFactory()
Ejemplo n.º 9
0
 def setUp(self):
     super(TestNodeSettings, self).setUp()
     self.node = ProjectFactory()
     self.settings = ForwardSettingsFactory(owner=self.node)
     self.node.save()