# Path: blackbelt/dependencies.py
# def parse_dep(dep):
#     split_result = re.split(r'==|@', dep)
#     if split_result[0] != '':
#         try:
#             return (split_result[0], split_result[1])
#         except IndexError:
#             return (split_result[0], 'latest')
#     else:
#         try:
#             return ('@' + split_result[1], split_result[2])
#         except IndexError:
#             return ('@' + split_result[1], 'latest')
# 
# def parse_license_text(text):
#     license_text = (text or '').strip()
#     copyright_notice = detect_copyright_notice(license_text, require_year=True)
# 
#     # If the license doesn't contain any of the following words, it's suspicius
#     # and should be classified as "rubbish" (sometimes the license-checker picks
#     # up a README file without any real license text).
#     license_text_lc = license_text.lower()
#     if (
#         'software' not in license_text_lc and
#         'copyright' not in license_text_lc and
#         'license' not in license_text_lc
#     ):
#         return (None, None)
# 
#     if 'Apache License' in license_text:
#         return (copyright_notice, license_text)
# 
#     copyright_notice = detect_copyright_notice(license_text)
#     if copyright_notice:
#         license_text = text.split(copyright_notice)[1]
#         license_text = license_text.strip()
#         license_text = re.sub(r' +', ' ', license_text)
#         license_text = re.sub(r' ?(\r\n|\n)+ ?', remove_newlines_keep_paragraps, license_text)
#     return (copyright_notice, license_text)


from nose.tools import assert_equal
from blackbelt.dependencies import (
    parse_dep,
    parse_license_text,
)



class TestDependencyNameParsing(object):

    def test_no_version(self):
        assert_equal(parse_dep('react'), ('react', 'latest'))

    def test_at_separator(self):

# Path: blackbelt/dependencies.py
# def parse_dep(dep):
#     split_result = re.split(r'==|@', dep)
#     if split_result[0] != '':
#         try:
#             return (split_result[0], split_result[1])
#         except IndexError:
#             return (split_result[0], 'latest')
#     else:
#         try:
#             return ('@' + split_result[1], split_result[2])
#         except IndexError:
#             return ('@' + split_result[1], 'latest')
# 
# def parse_license_text(text):
#     license_text = (text or '').strip()
#     copyright_notice = detect_copyright_notice(license_text, require_year=True)
# 
#     # If the license doesn't contain any of the following words, it's suspicius
#     # and should be classified as "rubbish" (sometimes the license-checker picks
#     # up a README file without any real license text).
#     license_text_lc = license_text.lower()
#     if (
#         'software' not in license_text_lc and
#         'copyright' not in license_text_lc and
#         'license' not in license_text_lc
#     ):
#         return (None, None)
# 
#     if 'Apache License' in license_text:
#         return (copyright_notice, license_text)
# 
#     copyright_notice = detect_copyright_notice(license_text)
#     if copyright_notice:
#         license_text = text.split(copyright_notice)[1]
#         license_text = license_text.strip()
#         license_text = re.sub(r' +', ' ', license_text)
#         license_text = re.sub(r' ?(\r\n|\n)+ ?', remove_newlines_keep_paragraps, license_text)
#     return (copyright_notice, license_text)


# Path: test/test_dependencies.py
from nose.tools import assert_equal
from blackbelt.dependencies import (
    parse_dep,
    parse_license_text,
)




class TestDependencyNameParsing(object):

    def test_no_version(self):
        assert_equal(parse_dep('react'), ('react', 'latest'))

    def test_at_separator(self):

        assert_equal(parse_dep('react@16.2'), ('react', '16.2'))