# Path: stackalytics/processor/utils.py
# LOG = logging.getLogger(__name__)
# BAD_NAME_SUFFIXES = ['Ltd', 'Pvt', 'Inc', 'GmbH', 'AG', 'Corporation', 'Corp',
#                      'Company', 'Co', 'Group', 'Srl', 'Limited', 'LLC', 'IT']
# BAD_NAME_SUFFIXES_WITH_STOPS = ['S.p.A.', 's.r.o.', 'L.P.', 'B.V.', 'K.K.',
#                                 'd.o.o.']
# def init_config_and_logging(opts):
# def date_to_timestamp(d):
# def date_to_timestamp_ext(d):
# def member_date_to_timestamp(d):
# def iso8601_to_timestamp(s):
# def timestamp_to_date(timestamp):
# def timestamp_to_week(timestamp):
# def week_to_date(week):
# def timestamp_to_day(timestamp):
# def timestamp_to_utc_date(timestamp):
# def round_timestamp_to_day(timestamp):
# def check_email_validity(email):
# def _session_request(session, uri, method):
# def do_request(uri, method='get', session=None):
# def read_uri(uri, session=None):
# def read_json_from_uri(uri, session=None):
# def read_yaml_from_uri(uri):
# def _gzip_decompress(content):
# def read_gzip_from_uri(uri):
# def get_uri_last_modified(uri):
# def cmp_to_key(mycmp):  # ported from python 3
#         def __init__(self, obj):
#         def __lt__(self, other):
#         def __gt__(self, other):
#         def __eq__(self, other):
#         def __le__(self, other):
#         def __ge__(self, other):
#         def __ne__(self, other):
# def make_range(start, stop, step):
# def load_repos(runtime_storage_inst):
# def unwrap_text(text):
# def format_text(s):
#     def replace_dots(match_obj):
# def make_age_string(seconds):
# def merge_records(original, new):
# def get_blueprint_id(module, name):
# def make_bug_id(bug_id, module, release=None):
# def get_patch_id(review_id, patch_number):
# def add_index(sequence, start=1, item_filter=lambda x: True):
# def safe_encode(s):
# def keep_safe_chars(s):
# def make_module_group(module_group_id, name=None, modules=None, tag='module'):
# def normalize_company_name(name):
# def normalize_company_draft(name):
# def validate_lp_display_name(lp_profile):
# def make_pipeline_processor(processors):
#     def get_passes(_processors):
#     def pipeline_processor(record_generator):
#     class K(object):


import mock
import testtools
from stackalytics.processor import utils
        original = 'tests.unit.benchmark.scenarios.test_base'
        expected = ('tests.&#8203;unit.&#8203;benchmark.&#8203;'
                    'scenarios.&#8203;test_base')

        self.assertEqual(expected, utils.format_text(original))

    def test_format_text_split_full_class_path_middle_line(self):
        original = 'some text tests.unit.benchmark.scenarios.test_base wide'
        expected = ('some text tests.&#8203;unit.&#8203;benchmark.&#8203;'
                    'scenarios.&#8203;test_base wide')

        self.assertEqual(expected, utils.format_text(original))

    def test_add_index(self):
        sequence = [{'name': 'A'}, {'name': 'B'}, {'name': 'C'}]
        expected = [{'index': 1, 'name': 'A'}, {'index': 2, 'name': 'B'},
                    {'index': 3, 'name': 'C'}]
        self.assertEqual(expected, utils.add_index(sequence))

    def test_add_index_with_filter(self):
        sequence = [{'name': 'A'}, {'name': 'B'}, {'name': 'C'}]
        expected = [{'index': 0, 'name': 'A'}, {'index': '', 'name': 'B'},
                    {'index': 1, 'name': 'C'}]
        self.assertEqual(expected, utils.add_index(
            sequence, start=0, item_filter=lambda x: x['name'] != 'B'))

    def test_keep_safe_chars(self):
        self.assertEqual('somemoretext',
                         utils.keep_safe_chars('some more text'))
        self.assertEqual(u'(unicode)',

# Path: stackalytics/processor/utils.py
# LOG = logging.getLogger(__name__)
# BAD_NAME_SUFFIXES = ['Ltd', 'Pvt', 'Inc', 'GmbH', 'AG', 'Corporation', 'Corp',
#                      'Company', 'Co', 'Group', 'Srl', 'Limited', 'LLC', 'IT']
# BAD_NAME_SUFFIXES_WITH_STOPS = ['S.p.A.', 's.r.o.', 'L.P.', 'B.V.', 'K.K.',
#                                 'd.o.o.']
# def init_config_and_logging(opts):
# def date_to_timestamp(d):
# def date_to_timestamp_ext(d):
# def member_date_to_timestamp(d):
# def iso8601_to_timestamp(s):
# def timestamp_to_date(timestamp):
# def timestamp_to_week(timestamp):
# def week_to_date(week):
# def timestamp_to_day(timestamp):
# def timestamp_to_utc_date(timestamp):
# def round_timestamp_to_day(timestamp):
# def check_email_validity(email):
# def _session_request(session, uri, method):
# def do_request(uri, method='get', session=None):
# def read_uri(uri, session=None):
# def read_json_from_uri(uri, session=None):
# def read_yaml_from_uri(uri):
# def _gzip_decompress(content):
# def read_gzip_from_uri(uri):
# def get_uri_last_modified(uri):
# def cmp_to_key(mycmp):  # ported from python 3
#         def __init__(self, obj):
#         def __lt__(self, other):
#         def __gt__(self, other):
#         def __eq__(self, other):
#         def __le__(self, other):
#         def __ge__(self, other):
#         def __ne__(self, other):
# def make_range(start, stop, step):
# def load_repos(runtime_storage_inst):
# def unwrap_text(text):
# def format_text(s):
#     def replace_dots(match_obj):
# def make_age_string(seconds):
# def merge_records(original, new):
# def get_blueprint_id(module, name):
# def make_bug_id(bug_id, module, release=None):
# def get_patch_id(review_id, patch_number):
# def add_index(sequence, start=1, item_filter=lambda x: True):
# def safe_encode(s):
# def keep_safe_chars(s):
# def make_module_group(module_group_id, name=None, modules=None, tag='module'):
# def normalize_company_name(name):
# def normalize_company_draft(name):
# def validate_lp_display_name(lp_profile):
# def make_pipeline_processor(processors):
#     def get_passes(_processors):
#     def pipeline_processor(record_generator):
#     class K(object):


# Path: stackalytics/tests/unit/test_utils.py
import mock
import testtools
from stackalytics.processor import utils

        original = 'tests.unit.benchmark.scenarios.test_base'
        expected = ('tests.&#8203;unit.&#8203;benchmark.&#8203;'
                    'scenarios.&#8203;test_base')

        self.assertEqual(expected, utils.format_text(original))

    def test_format_text_split_full_class_path_middle_line(self):
        original = 'some text tests.unit.benchmark.scenarios.test_base wide'
        expected = ('some text tests.&#8203;unit.&#8203;benchmark.&#8203;'
                    'scenarios.&#8203;test_base wide')

        self.assertEqual(expected, utils.format_text(original))

    def test_add_index(self):
        sequence = [{'name': 'A'}, {'name': 'B'}, {'name': 'C'}]
        expected = [{'index': 1, 'name': 'A'}, {'index': 2, 'name': 'B'},
                    {'index': 3, 'name': 'C'}]
        self.assertEqual(expected, utils.add_index(sequence))

    def test_add_index_with_filter(self):
        sequence = [{'name': 'A'}, {'name': 'B'}, {'name': 'C'}]
        expected = [{'index': 0, 'name': 'A'}, {'index': '', 'name': 'B'},
                    {'index': 1, 'name': 'C'}]
        self.assertEqual(expected, utils.add_index(
            sequence, start=0, item_filter=lambda x: x['name'] != 'B'))

    def test_keep_safe_chars(self):
        self.assertEqual('somemoretext',
                         utils.keep_safe_chars('some more text'))
        self.assertEqual(u'(unicode)',

                         utils.keep_safe_chars(u'(unicode \u0423) '))