-
-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #154 from soxoj/tests-improving
Improved tests
- Loading branch information
Showing
10 changed files
with
132 additions
and
18 deletions.
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
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
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,6 @@ | ||
flake8==3.8.4 | ||
pytest==6.2.4 | ||
pytest-asyncio==0.14.0 | ||
pytest-cov==2.10.1 | ||
pytest-httpserver==1.0.0 | ||
pytest-rerunfailures==9.1.1 |
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,21 @@ | ||
{ | ||
"engines": {}, | ||
"sites": { | ||
"StatusCode": { | ||
"checkType": "status_code", | ||
"url": "http://localhost:8989/url?id={username}", | ||
"urlMain": "http://localhost:8989/", | ||
"usernameClaimed": "claimed", | ||
"usernameUnclaimed": "unclaimed" | ||
}, | ||
"Message": { | ||
"checkType": "message", | ||
"url": "http://localhost:8989/url?id={username}", | ||
"urlMain": "http://localhost:8989/", | ||
"presenseStrs": ["user", "profile"], | ||
"absenseStrs": ["not found", "404"], | ||
"usernameClaimed": "claimed", | ||
"usernameUnclaimed": "unclaimed" | ||
} | ||
} | ||
} |
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,65 @@ | ||
from mock import Mock | ||
import pytest | ||
|
||
from maigret import search | ||
|
||
|
||
def site_result_except(server, username, **kwargs): | ||
query = f'id={username}' | ||
server.expect_request('/url', query_string=query).respond_with_data(**kwargs) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_checking_by_status_code(httpserver, local_test_db): | ||
sites_dict = local_test_db.sites_dict | ||
|
||
site_result_except(httpserver, 'claimed', status=200) | ||
site_result_except(httpserver, 'unclaimed', status=404) | ||
|
||
result = await search('claimed', site_dict=sites_dict, logger=Mock()) | ||
assert result['StatusCode']['status'].is_found() is True | ||
|
||
result = await search('unclaimed', site_dict=sites_dict, logger=Mock()) | ||
assert result['StatusCode']['status'].is_found() is False | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_checking_by_message_positive_full(httpserver, local_test_db): | ||
sites_dict = local_test_db.sites_dict | ||
|
||
site_result_except(httpserver, 'claimed', response_data="user profile") | ||
site_result_except(httpserver, 'unclaimed', response_data="404 not found") | ||
|
||
result = await search('claimed', site_dict=sites_dict, logger=Mock()) | ||
assert result['Message']['status'].is_found() is True | ||
|
||
result = await search('unclaimed', site_dict=sites_dict, logger=Mock()) | ||
assert result['Message']['status'].is_found() is False | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_checking_by_message_positive_part(httpserver, local_test_db): | ||
sites_dict = local_test_db.sites_dict | ||
|
||
site_result_except(httpserver, 'claimed', response_data="profile") | ||
site_result_except(httpserver, 'unclaimed', response_data="404") | ||
|
||
result = await search('claimed', site_dict=sites_dict, logger=Mock()) | ||
assert result['Message']['status'].is_found() is True | ||
|
||
result = await search('unclaimed', site_dict=sites_dict, logger=Mock()) | ||
assert result['Message']['status'].is_found() is False | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_checking_by_message_negative(httpserver, local_test_db): | ||
sites_dict = local_test_db.sites_dict | ||
|
||
site_result_except(httpserver, 'claimed', response_data="") | ||
site_result_except(httpserver, 'unclaimed', response_data="user 404") | ||
|
||
result = await search('claimed', site_dict=sites_dict, logger=Mock()) | ||
assert result['Message']['status'].is_found() is False | ||
|
||
result = await search('unclaimed', site_dict=sites_dict, logger=Mock()) | ||
assert result['Message']['status'].is_found() is True |
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