# Path: pypi_redirect/pypi_redirect/server_app/index_builder.py
# def build(index_rows):
# def _rows_for_file(package_filename, index_row):
# def _format_row(filename):
# def _escape_for_html(s, quote=False):
# 
# Path: pypi_redirect/pypi_redirect/server_app/index_parser.py
# def _all_internal_links_and_directories(html_root):
# def parse(
#         base_url,
#         package_path,
#         html_str,
#         strict_html=True,
#         find_links_fn=_all_internal_links_and_directories):
# def _parse_internal_links(base_url, html_root, package_path, find_links_fn):
# def _is_ascii(s):
# def _parse_html(html_str, strict_html):
# def _is_absolute_url(url):
# def _make_url_absolute(base_url, package_path, url):
# def _determine_checksums(href):


from collections import OrderedDict
from nose.tools import eq_
from _utils import read_index
from ...server_app import index_builder
from ...server_app.index_parser import IndexRow, Checksums
                    'https://pypi.python.org/simple/Sphinx/'
                    '../../packages/source/S/Sphinx/'
                    'Sphinx-0.1.61843.tar.gz'
                    '#md5=69ab7befe60af790d24e22b4b46e8392'),
                checksums=Checksums(
                    md5='69ab7befe60af790d24e22b4b46e8392',
                    sha1=None)))])

    _assert_parse_results(
        index_rows=index_rows,
        output_file='single_index_rebuilt.html')


def empty_index_test():
    _assert_parse_results(
        index_rows=OrderedDict(),
        output_file='empty_index_rebuilt.html')


def directory_index_test():
    index_rows = OrderedDict([
        ('Sphinx/', None),
        ('nose/', None)])

    _assert_parse_results(
        index_rows=index_rows,
        output_file='directory_index_rebuilt.html')


def _assert_parse_results(index_rows, output_file):

# Path: pypi_redirect/pypi_redirect/server_app/index_builder.py
# def build(index_rows):
# def _rows_for_file(package_filename, index_row):
# def _format_row(filename):
# def _escape_for_html(s, quote=False):
# 
# Path: pypi_redirect/pypi_redirect/server_app/index_parser.py
# def _all_internal_links_and_directories(html_root):
# def parse(
#         base_url,
#         package_path,
#         html_str,
#         strict_html=True,
#         find_links_fn=_all_internal_links_and_directories):
# def _parse_internal_links(base_url, html_root, package_path, find_links_fn):
# def _is_ascii(s):
# def _parse_html(html_str, strict_html):
# def _is_absolute_url(url):
# def _make_url_absolute(base_url, package_path, url):
# def _determine_checksums(href):


# Path: pypi_redirect/pypi_redirect/test/unit_tests/index_builder_test.py
from collections import OrderedDict
from nose.tools import eq_
from _utils import read_index
from ...server_app import index_builder
from ...server_app.index_parser import IndexRow, Checksums

                    'https://pypi.python.org/simple/Sphinx/'
                    '../../packages/source/S/Sphinx/'
                    'Sphinx-0.1.61843.tar.gz'
                    '#md5=69ab7befe60af790d24e22b4b46e8392'),
                checksums=Checksums(
                    md5='69ab7befe60af790d24e22b4b46e8392',
                    sha1=None)))])

    _assert_parse_results(
        index_rows=index_rows,
        output_file='single_index_rebuilt.html')


def empty_index_test():
    _assert_parse_results(
        index_rows=OrderedDict(),
        output_file='empty_index_rebuilt.html')


def directory_index_test():
    index_rows = OrderedDict([
        ('Sphinx/', None),
        ('nose/', None)])

    _assert_parse_results(
        index_rows=index_rows,
        output_file='directory_index_rebuilt.html')


def _assert_parse_results(index_rows, output_file):

    actual_html_str = index_builder.build(