コード例 #1
0
 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
     )
コード例 #2
0
 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
     )
コード例 #3
0
 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
     )
コード例 #4
0
 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
     )
コード例 #5
0
 def test_multiple_inputs_raises_valueerror(self):
     html = '<input id="foo" /><input id="bar" />'
     with self.assertRaises(ValueError):
         PlaceholderCharBlock.replace_placeholder(html, 'a')
コード例 #6
0
 def test_no_inputs_raises_valueerror(self):
     html = '<div>something</div>'
     with self.assertRaises(ValueError):
         PlaceholderCharBlock.replace_placeholder(html, 'a')
コード例 #7
0
 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"/>')
コード例 #8
0
 def test_replace_placeholder_quotes(self):
     html = '<input id="foo" placeholder="&quot;a&quot;" />'
     replaced = PlaceholderCharBlock.replace_placeholder(html, '"b"')
     self.assertEqual(replaced, '<input id="foo" placeholder=\'"b"\'/>')
コード例 #9
0
 def test_render_returns_safetext(self):
     block = PlaceholderCharBlock(placeholder='Hi there!')
     html = block.render_form('Hello world!')
     self.assertIsInstance(html, SafeText)
コード例 #10
0
 def test_multiple_inputs_raises_valueerror(self):
     html = '<input id="foo" /><input id="bar" />'
     with self.assertRaises(ValueError):
         PlaceholderCharBlock.replace_placeholder(html, 'a')
コード例 #11
0
 def test_no_inputs_raises_valueerror(self):
     html = '<div>something</div>'
     with self.assertRaises(ValueError):
         PlaceholderCharBlock.replace_placeholder(html, 'a')
コード例 #12
0
 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"/>')
コード例 #13
0
 def test_replace_placeholder_quotes(self):
     html = '<input id="foo" placeholder="&quot;a&quot;" />'
     replaced = PlaceholderCharBlock.replace_placeholder(html, '"b"')
     self.assertEqual(replaced, '<input id="foo" placeholder=\'"b"\'/>')
コード例 #14
0
 def test_render_returns_safetext(self):
     block = PlaceholderCharBlock(placeholder='Hi there!')
     html = block.render_form('Hello world!')
     self.assertIsInstance(html, SafeText)