Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
cgundy committed Dec 16, 2024
1 parent bfaaac1 commit c88bbd3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/python_lint_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ jobs:
flake8 reusable_workflows/
- name: Run all tests
run: pytest --runslow reusable_workflows/
run: pytest --integration-tests reusable_workflows/
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sorting/target
**/__pycache__
.env/**
.venv/**
14 changes: 7 additions & 7 deletions reusable_workflows/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@

def pytest_addoption(parser):
parser.addoption(
"--runslow", action="store_true", default=False, help="run slow tests"
"--integration-tests", action="store_true", default=False, help="run integration tests"
)


def pytest_configure(config):
config.addinivalue_line("markers", "slow: mark test as slow to run")
config.addinivalue_line("markers", "integration: mark test as integration test")


def pytest_collection_modifyitems(config, items):
if config.getoption("--runslow"):
# --runslow given in cli: do not skip slow tests
if config.getoption("--integration-tests"):
# --integration-tests given in cli: do not skip integration tests
return
skip_slow = pytest.mark.skip(reason="need --runslow option to run")
skip_integration = pytest.mark.skip(reason="need --integration-tests option to run")
for item in items:
if "slow" in item.keywords:
item.add_marker(skip_slow)
if "integration" in item.keywords:
item.add_marker(skip_integration)
7 changes: 7 additions & 0 deletions reusable_workflows/tests/test_check_external_contrib.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
from unittest import mock

import github3
import pytest

from check_membership.check_external_contrib import (
Expand Down Expand Up @@ -53,3 +54,9 @@ def test_github_token_not_passed_in(github_login_mock):
assert (
str(exc.value) == "github login failed - maybe GH_TOKEN was not correctly set"
)

@pytest.mark.integration
def test_check_repos_open_to_contributions_accessible():
gh = github3.login(token=os.getenv("GH_TOKEN"))

get_repos_open_to_contributions(gh)
4 changes: 2 additions & 2 deletions reusable_workflows/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_download_file_succeeds_first_try():
assert repo.file_contents.call_count == 1


@pytest.mark.slow
@pytest.mark.integration
def test_download_file_succeeds_third_try():
repo = mock.MagicMock()
file_content_obj = mock.Mock()
Expand All @@ -35,7 +35,7 @@ def test_download_file_succeeds_third_try():
assert repo.file_contents.call_count == 3


@pytest.mark.slow
@pytest.mark.integration
@mock.patch("requests.get")
def test_download_file_fails(mock_get):
repo = mock.MagicMock()
Expand Down

0 comments on commit c88bbd3

Please sign in to comment.