예제 #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()
예제 #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()
예제 #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))
예제 #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,
     })
예제 #5
0
 def setUp(self):
     super(TestSettingsValidation, self).setUp()
     self.settings = ForwardSettingsFactory()
예제 #6
0
 def test_settings_complete_false(self):
     node_settings = ForwardSettingsFactory(url=None)
     assert_false(utils.settings_complete(node_settings))
예제 #7
0
 def test_settings_complete_true(self):
     node_settings = ForwardSettingsFactory()
     assert_true(utils.settings_complete(node_settings))
예제 #8
0
 def setUp(self):
     super(TestSettingsValidation, self).setUp()
     self.settings = ForwardSettingsFactory()
예제 #9
0
 def setUp(self):
     super(TestNodeSettings, self).setUp()
     self.node = ProjectFactory()
     self.settings = ForwardSettingsFactory(owner=self.node)
     self.node.save()