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