# 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
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-

sys.path.append('..')


class TestDbProfilerFormatter(unittest.TestCase):
    def setUp(self):
        self.maxDiff = None

    def test_format_non_null_ratio_001(self):
        self.assertEqual('75.00 %', DbProfilerFormatter.format_non_null_ratio(100,25))
        self.assertEqual('100.00 %', DbProfilerFormatter.format_non_null_ratio(100,0))

        # N/A
        self.assertEqual('N/A', DbProfilerFormatter.format_non_null_ratio(100,None))
        self.assertEqual('N/A', DbProfilerFormatter.format_non_null_ratio(None,20))

    def test_format_cardinality_001(self):
        self.assertEqual('25.00 %', DbProfilerFormatter.format_cardinality(100,25,0))
        self.assertEqual('50.00 %', DbProfilerFormatter.format_cardinality(100,25,50))
        self.assertEqual('N/A', DbProfilerFormatter.format_cardinality(100,0,100))

        # N/A

# 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

#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-

sys.path.append('..')


class TestDbProfilerFormatter(unittest.TestCase):
    def setUp(self):
        self.maxDiff = None

    def test_format_non_null_ratio_001(self):
        self.assertEqual('75.00 %', DbProfilerFormatter.format_non_null_ratio(100,25))
        self.assertEqual('100.00 %', DbProfilerFormatter.format_non_null_ratio(100,0))

        # N/A
        self.assertEqual('N/A', DbProfilerFormatter.format_non_null_ratio(100,None))
        self.assertEqual('N/A', DbProfilerFormatter.format_non_null_ratio(None,20))

    def test_format_cardinality_001(self):
        self.assertEqual('25.00 %', DbProfilerFormatter.format_cardinality(100,25,0))
        self.assertEqual('50.00 %', DbProfilerFormatter.format_cardinality(100,25,50))
        self.assertEqual('N/A', DbProfilerFormatter.format_cardinality(100,0,100))

        # N/A

        self.assertEqual('N/A', DbProfilerFormatter.format_cardinality(None,25,50))