diff options
| author | Cody Logan <clpo13@gmail.com> | 2018-12-14 11:56:01 -0800 |
|---|---|---|
| committer | Cody Logan <clpo13@gmail.com> | 2018-12-14 11:56:01 -0800 |
| commit | fb42a66bf718098c382d6fb50f24f1c60a13f6e7 (patch) | |
| tree | 9fb670bb5a3c1665617cf813eaa9279d9b283f0c /test | |
| parent | 6e1164de98786bbe6c9bb0c16682e314811a0a9d (diff) | |
| download | wikiget-fb42a66bf718098c382d6fb50f24f1c60a13f6e7.tar.gz wikiget-fb42a66bf718098c382d6fb50f24f1c60a13f6e7.zip | |
Add some tests with pytest
Can be run with `pytest` (if installed) or `python setup.py test`
Diffstat (limited to 'test')
| -rw-r--r-- | test/test_wikiget.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/test_wikiget.py b/test/test_wikiget.py new file mode 100644 index 0000000..981d640 --- /dev/null +++ b/test/test_wikiget.py @@ -0,0 +1,45 @@ +"""wikiget +Simple wget clone for downloading files from Wikimedia sites. +Copyright (C) 2018 Cody Logan; licensed GPLv3+ +SPDX-License-Identifier: GPL-3.0-or-later +""" + +from wikiget import wikiget + + +def test_invalid_site_input(): + invalid_input = ["example.com", "vim.wikia.com", + "en.wikipedia.com", "en.wikimpedia.org"] + for i in invalid_input: + site_match = wikiget.valid_site(i) + assert site_match is None + + +def test_valid_site_input(): + valid_input = ["en.wikipedia.org", "commons.wikimedia.org", + "de.wikipedia.org", "meta.wikimedia.org"] + for i in valid_input: + site_match = wikiget.valid_site(i) + assert site_match is not None + + +def test_file_regex(): + i = "File:Example.jpg" + file_match = wikiget.valid_file(i) + assert file_match.group(0) + assert file_match.group(1) == "File:" + assert file_match.group(2) == "Example.jpg" + + +def test_invalid_file_input(): + invalid_input = ["file:example", "example"] + for i in invalid_input: + file_match = wikiget.valid_file(i) + assert file_match is None + + +def test_valid_file_input(): + valid_input = ["example.jpg", "file:example.jpg", "example.file-01.jpg"] + for i in valid_input: + file_match = wikiget.valid_file(i) + assert file_match is not None |
