from nose.tools import istest, assert_equal
from lxml import etree

from wordbridge import openxml
from wordbridge.htmlgeneration import HtmlGenerator
from wordbridge.html import HtmlBuilder

generator = HtmlGenerator()
html = HtmlBuilder()

@istest
def generating_html_for_document_concats_html_for_paragraphs():
    document = openxml.document([
        openxml.paragraph([
            openxml.run([
                openxml.text("Hello")
            ])
        ]),
        openxml.paragraph([
            openxml.run([
                openxml.text("there")
            ])
        ])
    ])
    expected_html = html.fragment([
        html.element("p", [html.text("Hello")]),
        html.element("p", [html.text("there")])
    ])
    assert_equal(expected_html, generator.for_document(document))

from nose.tools import istest, assert_equal
from lxml import etree

from wordbridge import openxml
from wordbridge.htmlgeneration import HtmlGenerator
from wordbridge.html import HtmlBuilder

html = HtmlBuilder()

@istest
def generating_html_for_document_concats_html_for_paragraphs():
    document = openxml.document([
        openxml.paragraph([
            openxml.run([
                openxml.text("Hello")
            ])
        ]),
        openxml.paragraph([
            openxml.run([
                openxml.text("there")
            ])
        ])
    ])
    expected_html = html.fragment([
        html.element("p", [html.text("Hello")]),
        html.element("p", [html.text("there")])
    ])
    
    generator = HtmlGenerator()
    assert_equal(expected_html, generator.for_document(document))

@istest
def html_for_paragraph_uses_p_tag_if_there_is_no_style():
    paragraph = openxml.paragraph([
        openxml.run([
            openxml.text("Hello")
        ])
    ])
    expected_html = html.element("p", [html.text("Hello")])
    
    generator = HtmlGenerator()
    assert_equal(expected_html, generator.for_paragraph(paragraph))

Add test just for paragraph HTML generation
Add test just for paragraph HTML generation

  from nose.tools import istest, assert_equal
  from lxml import etree
  
  from wordbridge import openxml
  from wordbridge.htmlgeneration import HtmlGenerator
  from wordbridge.html import HtmlBuilder
  
- generator = HtmlGenerator()
  html = HtmlBuilder()
  
  @istest
  def generating_html_for_document_concats_html_for_paragraphs():
      document = openxml.document([
          openxml.paragraph([
              openxml.run([
                  openxml.text("Hello")
              ])
          ]),
          openxml.paragraph([
              openxml.run([
                  openxml.text("there")
              ])
          ])
      ])
      expected_html = html.fragment([
          html.element("p", [html.text("Hello")]),
          html.element("p", [html.text("there")])
      ])
+     
+     generator = HtmlGenerator()
      assert_equal(expected_html, generator.for_document(document))
  
+ @istest
+ def html_for_paragraph_uses_p_tag_if_there_is_no_style():
+     paragraph = openxml.paragraph([
+         openxml.run([
+             openxml.text("Hello")
+         ])
+     ])
+     expected_html = html.element("p", [html.text("Hello")])
+     
+     generator = HtmlGenerator()
+     assert_equal(expected_html, generator.for_paragraph(paragraph))
+ 
Add test just for paragraph HTML generation
## Code Before:
from nose.tools import istest, assert_equal
from lxml import etree

from wordbridge import openxml
from wordbridge.htmlgeneration import HtmlGenerator
from wordbridge.html import HtmlBuilder

generator = HtmlGenerator()
html = HtmlBuilder()

@istest
def generating_html_for_document_concats_html_for_paragraphs():
    document = openxml.document([
        openxml.paragraph([
            openxml.run([
                openxml.text("Hello")
            ])
        ]),
        openxml.paragraph([
            openxml.run([
                openxml.text("there")
            ])
        ])
    ])
    expected_html = html.fragment([
        html.element("p", [html.text("Hello")]),
        html.element("p", [html.text("there")])
    ])
    assert_equal(expected_html, generator.for_document(document))

## Instruction:
Add test just for paragraph HTML generation
## Code After:
from nose.tools import istest, assert_equal
from lxml import etree

from wordbridge import openxml
from wordbridge.htmlgeneration import HtmlGenerator
from wordbridge.html import HtmlBuilder

html = HtmlBuilder()

@istest
def generating_html_for_document_concats_html_for_paragraphs():
    document = openxml.document([
        openxml.paragraph([
            openxml.run([
                openxml.text("Hello")
            ])
        ]),
        openxml.paragraph([
            openxml.run([
                openxml.text("there")
            ])
        ])
    ])
    expected_html = html.fragment([
        html.element("p", [html.text("Hello")]),
        html.element("p", [html.text("there")])
    ])
    
    generator = HtmlGenerator()
    assert_equal(expected_html, generator.for_document(document))

@istest
def html_for_paragraph_uses_p_tag_if_there_is_no_style():
    paragraph = openxml.paragraph([
        openxml.run([
            openxml.text("Hello")
        ])
    ])
    expected_html = html.element("p", [html.text("Hello")])
    
    generator = HtmlGenerator()
    assert_equal(expected_html, generator.for_paragraph(paragraph))
