forked from MikeMeliz/TorCrawl.py
-
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.
- Adds tests folder under 'modules'. - Creates test files for modules. - Implements checker passing test cases. See Issue: MikeMeliz#16
- Loading branch information
1 parent
3571797
commit d3d4a64
Showing
4 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,69 @@ | ||
import os.path | ||
import unittest | ||
|
||
from ..checker import extract_domain | ||
from ..checker import folder | ||
from ..checker import url_canon | ||
|
||
|
||
class TestCheckFunctions(unittest.TestCase): | ||
@classmethod | ||
def setUp(cls) -> None: | ||
pass | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
""" Test Suite Teardown. """ | ||
# Remove test folder. | ||
os.rmdir('torcrawl') | ||
|
||
def test_url_canon_001(self): | ||
""" url_canon unit test. | ||
Returns true if the function successfully performs URL normalisation. | ||
""" | ||
url = 'torcrawl.com' | ||
expected = 'http://www.torcrawl.com' | ||
result = url_canon(url, False) | ||
self.assertEqual(expected, result, | ||
f'Test Fail:: expected = {expected}, got {result}') | ||
|
||
def test_url_canon_002(self): | ||
""" url_canon unit test. | ||
Returns true if the function successfully performs URL normalisation. | ||
""" | ||
url = 'www.torcrawl.com' | ||
expected = 'http://www.torcrawl.com' | ||
result = url_canon(url, False) | ||
self.assertEqual(expected, result, | ||
f'Test Fail:: expected = {expected}, got {result}') | ||
|
||
def test_extract_domain_001(self): | ||
""" extract_domain test. | ||
Returns true if correct domain is returned. | ||
""" | ||
url = 'http://www.torcrawl.com/test/domain-extract/api?id=001' | ||
expected = 'www.torcrawl.com' | ||
result = extract_domain(url, True) | ||
self.assertEqual(expected, result, | ||
f'Test Fail:: expected = {expected}, got {result}') | ||
|
||
def test_extract_domain_002(self): | ||
""" extract_domain test. | ||
Returns true if correct domain is returned. | ||
""" | ||
url = 'http://www.torcrawl.com/test/domain-extract/api?id=002' | ||
expected = 'http://www.torcrawl.com' | ||
result = extract_domain(url, False) | ||
self.assertEqual(expected, result, | ||
f'Test Fail:: expected = {expected}, got {result}') | ||
|
||
def test_folder_creation(self): | ||
""" folder creation test. | ||
Returns true if folder is successfully created. | ||
""" | ||
_input = 'torcrawl' | ||
result = folder(_input, False) | ||
self.assertTrue(os.path.exists(result), | ||
f'Test Fail:: could not find folder {_input}') | ||
|
||
|
Empty file.
Empty file.