# Path: hecatoncheir/DbProfilerFormatter.py
# def format_non_null_ratio(rows, nulls):
# def format_cardinality(rows, cardinality, nulls):
# def format_data_type(d1, d2):
# def format_value_freq_ratio(rows, nulls, freq):
# def get_validation_rule(column_name, rule, invalid):
# def filter_markdown2html(text):
# def filter_term2popover(html, pos, term, content, orig=None):
# def create_popover_content(term):
# def filter_glossaryterms(html, glossary_terms):
# def format_comment_tooltip(msg, maxlen=20):
# def get_default_template_path():
# def format_number(value):
# def format_minmax(minval, maxval):
# def is_column_unique(most_freq_vals):
# def format_fks(dbname, fks):
# def format_freq_values(freq_vals, row_count, nulls):
# def format_validation_item(val):
# def format_validation_items(vals):
# def filter_plain2html(s):
# def format_table_datamapping(datamapping):
# def format_column_datamapping(datamapping, column_name):
# def format_column_metadata(colmeta, tabmeta, row_count, glossary_terms,
#                            datamapping):
# def format_table_metadata(tabmeta, glossary_terms, datamapping=None):
# def to_table_html(tabdata, validation_rules=None, datamapping=None,
#                   files=None,
#                   glossary_terms=None, template_file=None, editable=False):
# def format_timestamp(ts):
# def get_template_from_file(filename, encoding='utf-8'):
# def to_index_html(data, reponame, schemas=None, tags=None,
#                   show_validation='none', comment=None,
#                   files=None, glossary_terms=None,
#                   template_file=None, editable=False, max_panels=99):
# def to_glossary_html(glossary_terms=None, template_file=None, editable=False):
# 
# Path: hecatoncheir/exception.py
# class DbProfilerException(Exception):
#     source = None
# 
#     def __init__(self, value, source=None):
#         self.value = value
#         self.source = source
# 
#     def __str__(self):
#         return self.value
# 
# class InternalError(Exception):
#     source = None
#     query = None
# 
#     def __init__(self, value, query=None, source=None):
#         self.value = value
#         self.query = query
#         self.source = source
# 
#     def __str__(self):
#         return self.value


import json
import os
import re
import sys
import unittest
from hecatoncheir import DbProfilerFormatter
from hecatoncheir.exception import DbProfilerException, InternalError
        self.assertEqual(a, DbProfilerFormatter.create_popover_content(t))

        t['related_terms'] = ['c','d']
        a = u"desc<br/><br/>Synonym: a, b<br/>Related Terms: c, d<div align=right><a href='glossary.html#aa' target='_glossary'>Details...</a></div>"
        self.assertEqual(a, DbProfilerFormatter.create_popover_content(t))

        t['assigned_assets'] = ['e', 'f']
        a = u"desc<br/><br/>Synonym: a, b<br/>Related Terms: c, d<br/>Assigned Assets: e, f<div align=right><a href='glossary.html#aa' target='_glossary'>Details...</a></div>"
        self.assertEqual(a, DbProfilerFormatter.create_popover_content(t))

    def test_filter_glossaryterms_001(self):
        terms = [{'term': 'PV', 'description_short': 'Page Views'}]

        html = 'foo'
        a = 'foo'
        self.assertEqual(a, DbProfilerFormatter.filter_glossaryterms(html, terms))

        html = 'foo PV bar'
        a = u'foo <a tabindex="0" data-toggle="popover" data-trigger="focus" data-html="true" title="PV" data-content="Page Views<br/><div align=right><a href=\'glossary.html#PV\' target=\'_glossary\'>Details...</a></div>" class="glossary-term">PV</a> bar'
        self.assertEqual(a, DbProfilerFormatter.filter_glossaryterms(html, terms))

    def test_format_number_001(self):
        self.assertEqual('1', DbProfilerFormatter.format_number('001'))
        self.assertEqual('100', DbProfilerFormatter.format_number('100'))
        self.assertEqual('1,000', DbProfilerFormatter.format_number('1000'))
        self.assertEqual('1,000,000', DbProfilerFormatter.format_number('1000000'))

        self.assertEqual('N/A', DbProfilerFormatter.format_number(''))
        self.assertEqual('N/A', DbProfilerFormatter.format_number(None))


# Path: hecatoncheir/DbProfilerFormatter.py
# def format_non_null_ratio(rows, nulls):
# def format_cardinality(rows, cardinality, nulls):
# def format_data_type(d1, d2):
# def format_value_freq_ratio(rows, nulls, freq):
# def get_validation_rule(column_name, rule, invalid):
# def filter_markdown2html(text):
# def filter_term2popover(html, pos, term, content, orig=None):
# def create_popover_content(term):
# def filter_glossaryterms(html, glossary_terms):
# def format_comment_tooltip(msg, maxlen=20):
# def get_default_template_path():
# def format_number(value):
# def format_minmax(minval, maxval):
# def is_column_unique(most_freq_vals):
# def format_fks(dbname, fks):
# def format_freq_values(freq_vals, row_count, nulls):
# def format_validation_item(val):
# def format_validation_items(vals):
# def filter_plain2html(s):
# def format_table_datamapping(datamapping):
# def format_column_datamapping(datamapping, column_name):
# def format_column_metadata(colmeta, tabmeta, row_count, glossary_terms,
#                            datamapping):
# def format_table_metadata(tabmeta, glossary_terms, datamapping=None):
# def to_table_html(tabdata, validation_rules=None, datamapping=None,
#                   files=None,
#                   glossary_terms=None, template_file=None, editable=False):
# def format_timestamp(ts):
# def get_template_from_file(filename, encoding='utf-8'):
# def to_index_html(data, reponame, schemas=None, tags=None,
#                   show_validation='none', comment=None,
#                   files=None, glossary_terms=None,
#                   template_file=None, editable=False, max_panels=99):
# def to_glossary_html(glossary_terms=None, template_file=None, editable=False):
# 
# Path: hecatoncheir/exception.py
# class DbProfilerException(Exception):
#     source = None
# 
#     def __init__(self, value, source=None):
#         self.value = value
#         self.source = source
# 
#     def __str__(self):
#         return self.value
# 
# class InternalError(Exception):
#     source = None
#     query = None
# 
#     def __init__(self, value, query=None, source=None):
#         self.value = value
#         self.query = query
#         self.source = source
# 
#     def __str__(self):
#         return self.value


# Path: tests/testDbProfilerFormatter.py
import json
import os
import re
import sys
import unittest
from hecatoncheir import DbProfilerFormatter
from hecatoncheir.exception import DbProfilerException, InternalError

        self.assertEqual(a, DbProfilerFormatter.create_popover_content(t))

        t['related_terms'] = ['c','d']
        a = u"desc<br/><br/>Synonym: a, b<br/>Related Terms: c, d<div align=right><a href='glossary.html#aa' target='_glossary'>Details...</a></div>"
        self.assertEqual(a, DbProfilerFormatter.create_popover_content(t))

        t['assigned_assets'] = ['e', 'f']
        a = u"desc<br/><br/>Synonym: a, b<br/>Related Terms: c, d<br/>Assigned Assets: e, f<div align=right><a href='glossary.html#aa' target='_glossary'>Details...</a></div>"
        self.assertEqual(a, DbProfilerFormatter.create_popover_content(t))

    def test_filter_glossaryterms_001(self):
        terms = [{'term': 'PV', 'description_short': 'Page Views'}]

        html = 'foo'
        a = 'foo'
        self.assertEqual(a, DbProfilerFormatter.filter_glossaryterms(html, terms))

        html = 'foo PV bar'
        a = u'foo <a tabindex="0" data-toggle="popover" data-trigger="focus" data-html="true" title="PV" data-content="Page Views<br/><div align=right><a href=\'glossary.html#PV\' target=\'_glossary\'>Details...</a></div>" class="glossary-term">PV</a> bar'
        self.assertEqual(a, DbProfilerFormatter.filter_glossaryterms(html, terms))

    def test_format_number_001(self):
        self.assertEqual('1', DbProfilerFormatter.format_number('001'))
        self.assertEqual('100', DbProfilerFormatter.format_number('100'))
        self.assertEqual('1,000', DbProfilerFormatter.format_number('1000'))
        self.assertEqual('1,000,000', DbProfilerFormatter.format_number('1000000'))

        self.assertEqual('N/A', DbProfilerFormatter.format_number(''))
        self.assertEqual('N/A', DbProfilerFormatter.format_number(None))


        with self.assertRaises(InternalError) as cm: