-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
945c2ab
commit 84ebb38
Showing
3 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"""Test scrap image from keywords | ||
""" | ||
|
||
if __name__ == "__main__": | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"""Tests IO scrap functions | ||
""" | ||
import pytest | ||
|
||
from ascii_art.io.scrap import create_header | ||
from ascii_art.io.scrap import get_data_from_url | ||
from ascii_art.io.scrap import get_img_url_list_from_keyword | ||
from ascii_art.io.scrap import scrap_img_on_bing | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"url, host", | ||
[ | ||
("http://test.com", "test.com"), | ||
("http://i.am.an.url.com", "i.am.an.url.com"), | ||
], | ||
) | ||
def test_create_header(url, host): | ||
"""Test the function create header with correct input""" | ||
header = create_header(url) | ||
assert header["Host"] == host | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"url", | ||
[10, 1.2, ["http://error.com"]], | ||
) | ||
def test_create_header_typeerror(url): | ||
"""Test the function create header with incorrect input""" | ||
|
||
with pytest.raises(TypeError): | ||
create_header(url) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"url", | ||
["not_an_url", "http:/test.com", "https//42.fr"], | ||
) | ||
def test_create_header_url_http_error(url): | ||
"""Test the function create header with string but not url""" | ||
|
||
with pytest.raises(ValueError): | ||
create_header(url) |