def test_render_no_placeholder_provided(self): block = PlaceholderCharBlock() html = block.render_form('Hello world!') self.assertInHTML( ( '<input id="" name="" placeholder="" ' 'type="text" value="Hello world!" />' ), html )
def test_render_with_placeholder(self): block = PlaceholderCharBlock(placeholder='Hi there!') html = block.render_form('Hello world!') self.assertIn( ( '<input id="" name="" placeholder="Hi there!" ' 'type="text" value="Hello world!"/>' ), html )
def test_render_no_placeholder_provided(self): block = PlaceholderCharBlock() html = block.render_form('Hello world!') self.assertIn( ( '<input id="" name="" placeholder="" ' 'type="text" value="Hello world!" />' ), html )
def test_multiple_inputs_raises_valueerror(self): html = '<input id="foo" /><input id="bar" />' with self.assertRaises(ValueError): PlaceholderCharBlock.replace_placeholder(html, 'a')
def test_no_inputs_raises_valueerror(self): html = '<div>something</div>' with self.assertRaises(ValueError): PlaceholderCharBlock.replace_placeholder(html, 'a')
def test_replace_placeholder_no_placeholder(self): html = '<input id="foo" />' replaced = PlaceholderCharBlock.replace_placeholder(html, 'a') self.assertEqual(replaced, '<input id="foo" placeholder="a"/>')
def test_replace_placeholder_quotes(self): html = '<input id="foo" placeholder=""a"" />' replaced = PlaceholderCharBlock.replace_placeholder(html, '"b"') self.assertEqual(replaced, '<input id="foo" placeholder=\'"b"\'/>')
def test_render_returns_safetext(self): block = PlaceholderCharBlock(placeholder='Hi there!') html = block.render_form('Hello world!') self.assertIsInstance(html, SafeText)