-
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.
* - Bug fixing * - Performance optimization adblockparser * - Correcting tag list urls - * - WIP: Replace asyncio with multiprocessing * - Resolved bug of missing logger * - Replace asyncio with multiprocessing * - Cleanup * - Cleanup - Making long running adblockparsing processes async and parallel * - Implementing _astart for html based features * - Removing unneeded allowlists - Reducing number of rools per pool * - Test coverage * - WIP: Building tests * - WIP: Thoughts * - Reverting parallel processing for simplification * - Adding advertisment feature integration test
- Loading branch information
1 parent
0a73de4
commit 6b1aaf6
Showing
3 changed files
with
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from features.html_based import Advertisement | ||
from features.website_manager import WebsiteData, WebsiteManager | ||
from lib.logger import create_logger | ||
|
||
# TODO Check other features, e.g. adult: | ||
# html = { | ||
# "html": "9content.com\n,ytimm.com\n,boyzshop.com/affimages/", | ||
# "har": "", | ||
# "url": "", | ||
# } | ||
# expected = { | ||
# "easylist_adult": { | ||
# "values": ["9content.com", "ad_slot="], | ||
# "runs_within": 10, # time the evaluation may take AT MAX -> acceptance test} | ||
# } | ||
# } | ||
|
||
|
||
def test_advertisement(mocker): | ||
_logger = create_logger() | ||
|
||
advertisement = Advertisement(_logger) | ||
|
||
advertisement.setup() | ||
website_manager = WebsiteManager.get_instance() | ||
|
||
html = { | ||
"html": "ad_block, ad_slot= mallorcash.com admanmedia murkymouse.online", | ||
"har": "", | ||
"url": "", | ||
"headers": "{}", | ||
} | ||
expected = { | ||
"advertisement": { | ||
"values": [], # ["ad_block", "ad_slot="] | ||
"runs_within": 10, # time the evaluation may take AT MAX -> acceptance test | ||
}, | ||
} | ||
|
||
website_manager.load_raw_data(html) | ||
website_data = WebsiteData(html=html["html"], raw_header="", headers={}) | ||
website_data.raw_links = [html["html"]] | ||
website_data.html = html["html"] | ||
|
||
data = advertisement.start() | ||
|
||
website_manager.reset() | ||
|
||
assert ( | ||
data["advertisement"]["values"] == expected["advertisement"]["values"] | ||
) | ||
runs_fast_enough = ( | ||
data["advertisement"]["time_required"] | ||
<= expected["advertisement"]["runs_within"] | ||
) | ||
assert runs_fast_enough |
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