Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #103 from avats-dev/less-verbose-titles
Browse files Browse the repository at this point in the history
less verbose parametrized titles for test_create_base_link
  • Loading branch information
TimidRobot authored Sep 4, 2020
2 parents d138c2c + dd6b36b commit e87feae
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 54 deletions.
99 changes: 55 additions & 44 deletions link_checker/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,52 +43,63 @@ def test_get_github_legalcode():
assert len(all_links) > 0


license_url_data = [
# 2 part URL
(
"by-nc-nd_2.0",
"https://creativecommons.org/licenses/by-nc-nd/2.0/legalcode",
"https://creativecommons.org/licenses/by-nc-nd/2.0/",
"https://creativecommons.org/licenses/by-nc-nd/2.0/rdf",
),
# 3 part URL
(
"by-nc-nd_4.0_cs",
"https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode.cs",
"https://creativecommons.org/licenses/by-nc-nd/4.0/deed.cs",
"https://creativecommons.org/licenses/by-nc-nd/4.0/rdf",
),
# 4 part URL
(
"by-nc-nd_3.0_rs_sr-Latn",
"https://creativecommons.org/licenses/by-nc-nd/3.0/rs/"
"legalcode.sr-Latn",
"https://creativecommons.org/licenses/by-nc-nd/3.0/rs/",
"https://creativecommons.org/licenses/by-nc-nd/3.0/rs/rdf",
),
# Special case - samplingplus
(
"samplingplus_1.0",
"https://creativecommons.org/licenses/sampling+/1.0/legalcode",
"https://creativecommons.org/licenses/sampling+/1.0/",
"https://creativecommons.org/licenses/sampling+/1.0/rdf",
),
(
"samplingplus_1.0_br",
"https://creativecommons.org/licenses/sampling+/1.0/br/legalcode",
"https://creativecommons.org/licenses/sampling+/1.0/br/",
"https://creativecommons.org/licenses/sampling+/1.0/br/rdf",
),
# Special case - CC0
(
"zero_1.0",
"https://creativecommons.org/publicdomain/zero/1.0/legalcode",
"https://creativecommons.org/publicdomain/zero/1.0/",
"https://creativecommons.org/publicdomain/zero/1.0/rdf",
),
]


def id_generator(data):
id_list = []
for license in data:
id_list.append(license[0])
return id_list


@pytest.mark.parametrize(
"filename, result, deed_result, rdf_result",
[
# 2 part URL
(
"by-nc-nd_2.0",
"https://creativecommons.org/licenses/by-nc-nd/2.0/legalcode",
"https://creativecommons.org/licenses/by-nc-nd/2.0/",
"https://creativecommons.org/licenses/by-nc-nd/2.0/rdf",
),
# 3 part URL
(
"by-nc-nd_4.0_cs",
"https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode.cs",
"https://creativecommons.org/licenses/by-nc-nd/4.0/deed.cs",
"https://creativecommons.org/licenses/by-nc-nd/4.0/rdf",
),
# 4 part URL
(
"by-nc-nd_3.0_rs_sr-Latn",
"https://creativecommons.org/licenses/by-nc-nd/3.0/rs/"
"legalcode.sr-Latn",
"https://creativecommons.org/licenses/by-nc-nd/3.0/rs/",
"https://creativecommons.org/licenses/by-nc-nd/3.0/rs/rdf",
),
# Special case - samplingplus
(
"samplingplus_1.0",
"https://creativecommons.org/licenses/sampling+/1.0/legalcode",
"https://creativecommons.org/licenses/sampling+/1.0/",
"https://creativecommons.org/licenses/sampling+/1.0/rdf",
),
(
"samplingplus_1.0_br",
"https://creativecommons.org/licenses/sampling+/1.0/br/legalcode",
"https://creativecommons.org/licenses/sampling+/1.0/br/",
"https://creativecommons.org/licenses/sampling+/1.0/br/rdf",
),
# Special case - CC0
(
"zero_1.0",
"https://creativecommons.org/publicdomain/zero/1.0/legalcode",
"https://creativecommons.org/publicdomain/zero/1.0/",
"https://creativecommons.org/publicdomain/zero/1.0/rdf",
),
],
license_url_data,
ids=id_generator(license_url_data),
)
def test_create_base_link(filename, result, deed_result, rdf_result):
args = link_checker.parse_argument([])
Expand Down
19 changes: 9 additions & 10 deletions link_checker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,14 +448,14 @@ def create_base_link(args, filename, for_deeds=False, for_rdfs=False):
def create_absolute_link(base_url, link_analysis):
"""Creates absolute links from relative links
Args:
base_url (string): URL on which the license page will be displayed
link_analysis (class 'urllib.parse.SplitResult'): Link splitted by
urlsplit, that is to be converted
Returns:
str: absolute link
"""
Args:
base_url (string): URL on which the license page will be displayed
link_analysis (class 'urllib.parse.SplitResult'): Link splitted by
urlsplit, that is to be converted
Returns:
str: absolute link
"""
href = link_analysis.geturl()
# Check for relative link
if (
Expand Down Expand Up @@ -607,8 +607,7 @@ def map_links_file(link, file_url):


def output_write(args, *args_, **kwargs):
"""Prints to output file is --output-error flag is set
"""
"""Prints to output file is --output-error flag is set"""
if args.output_errors:
kwargs["file"] = args.output_errors
print(*args_, **kwargs)
Expand Down

0 comments on commit e87feae

Please sign in to comment.