-
Notifications
You must be signed in to change notification settings - Fork 15
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
2f0b403
commit bcce4aa
Showing
6 changed files
with
76 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,26 @@ | ||
name: Python app | ||
name: Static analysis checks and unit tests | ||
|
||
on: [push] | ||
on: [pull_request, push, workflow_dispatch] | ||
|
||
jobs: | ||
lint: | ||
|
||
lint_and_tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Run Prospector | ||
- name: Run static analysis | ||
run: prospector -X | ||
|
||
- name: Run unit tests | ||
run: pytest |
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
strictness: medium | ||
|
||
test-warnings: true | ||
|
||
pylint: | ||
disable: | ||
- invalid-name |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
colorama==0.3.9 | ||
prospector==1.9.0 | ||
pytest | ||
selenium | ||
tldextract==3.1.2 | ||
tranco==0.7.1 | ||
|
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,39 @@ | ||
import pytest | ||
|
||
import crawler | ||
|
||
from tranco import Tranco | ||
|
||
|
||
class TestSitelist: | ||
|
||
@pytest.mark.parametrize("num_sites, exclude, expected", [ | ||
(10, None, ["example.com", "example.net", "example.org"]), | ||
(1, None, ["example.com"]), | ||
(10, ".com", ["example.net", "example.org"]), | ||
(10, ".gov,.mil,.net,.org", ["example.com"]), | ||
(1, ".gov", ["example.com"])]) | ||
def test_exclude_suffixes(self, monkeypatch, num_sites, exclude, expected): | ||
args = [f"--num-sites={num_sites}"] | ||
if exclude: | ||
args.append("--exclude=" + exclude) | ||
cr = crawler.Crawler(crawler.create_argument_parser().parse_args(args)) | ||
|
||
# mock out Tranco list | ||
class MockResponse: | ||
def top(self): | ||
return ["example.com", "example.net", "example.org"] | ||
|
||
def mock_get(self, list_version): # pylint:disable=unused-argument | ||
return MockResponse() | ||
|
||
monkeypatch.setattr(Tranco, "list", mock_get) | ||
|
||
# also clear exclude_domains | ||
monkeypatch.setattr(cr, "exclude_domains", set()) | ||
|
||
assert cr.get_domain_list() == expected | ||
|
||
@pytest.mark.skip() | ||
def test_recently_failed_domains(self): | ||
pass |