def test_para_with_mixture_of_types(self):
     img = Img("picture.png")
     ahref = Link("http://example.com")
     p = Para("Beautiful picture:", img, "See more at", ahref)
     self.assertEqual(
         p.html(), "<p>Beautiful picture: "
         "<img src='picture.png' /> "
         "See more at "
         "<a href='http://example.com'>"
         "http://example.com</a></p>")
 def test_target_with_link(self):
     tgt = Target("my_target")
     ahref = Link("My target", tgt)
     self.assertEqual(ahref.href, "#my_target")
     self.assertEqual(ahref.html(), "<a href='#my_target'>My target</a>")
 def test_link_to_section(self):
     s = Section("Introduction", name='intro_section')
     ahref = Link("Introduction", s)
     self.assertEqual(ahref.href, "#intro_section")
     self.assertEqual(ahref.html(),
                      "<a href='#intro_section'>Introduction</a>")
 def test_link_no_target(self):
     ahref = Link("http://example.com/report.html")
     self.assertEqual(ahref.href, "http://example.com/report.html")
     self.assertEqual(
         ahref.html(), "<a href='http://example.com/report.html'>"
         "http://example.com/report.html</a>")
 def test_link(self):
     ahref = Link("My report", "report.html")
     self.assertEqual(ahref.href, "report.html")
     self.assertEqual(ahref.html(), "<a href='report.html'>My report</a>")
    # Make a HTML report
    report = Document(title="ICell8 processing summary")
    report.add_css_rule(css_rules.QC_REPORT_CSS_RULES)
    report.add_css_rule("body { border: solid 1px grey;\n"
                        "       font-size: 80%;\n"
                        "       font-family: sans-serif; }")

    # Table of contents
    toc = report.add_section("Contents", name="toc")
    toc_list = List()
    toc.add(toc_list)

    # Files
    files_info = report.add_section("Stats files")
    stats_files = "Statistics: %s" % Link(
        "[TSV]", os.path.relpath(stats_file, os.path.dirname(out_file)))
    if xlsx_file is not None:
        stats_files += " | %s" % Link(
            "[XLSX]", os.path.relpath(xlsx_file, os.path.dirname(out_file)))
    files_info.add(stats_files)
    toc_list.add_item(Link(files_info.title, files_info))

    # General info
    general_info = report.add_section("General info", name="general_info")
    tbl = Table(columns=('name', 'value'))
    tbl.no_header()
    data_items = (('Total #reads', 'total_reads'), ('Total assigned #reads',
                                                    'total_assigned_reads'),
                  ('Total #barcodes', 'total_barcodes'), ('Assigned #barcodes',
                                                          'assigned_barcodes'))
    for item in data_items: