Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-45079: Move test data #360

Merged
merged 2 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions tests/business/notebookrunner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from mobu.storage.git import Git

from ..support.constants import TEST_DATA_DIR
from ..support.gafaelfawr import mock_gafaelfawr
from ..support.jupyter import MockJupyter
from ..support.util import wait_for_business, wait_for_log_message
Expand All @@ -39,7 +40,7 @@ async def test_run(
cwd = Path.cwd()

# Set up a notebook repository.
source_path = Path(__file__).parent.parent / "notebooks"
source_path = TEST_DATA_DIR / "notebooks"
repo_path = tmp_path / "notebooks"

shutil.copytree(str(source_path), str(repo_path))
Expand Down Expand Up @@ -119,7 +120,7 @@ async def test_run_recursive(
cwd = Path.cwd()

# Set up a notebook repository.
source_path = Path(__file__).parent.parent / "notebooks_recursive"
source_path = TEST_DATA_DIR / "notebooks_recursive"
repo_path = tmp_path / "notebooks"

shutil.copytree(str(source_path), str(repo_path))
Expand Down Expand Up @@ -219,7 +220,7 @@ async def test_refresh(
cwd = Path.cwd()

# Set up a notebook repository.
source_path = Path(__file__).parent.parent / "notebooks"
source_path = TEST_DATA_DIR / "notebooks"
repo_path = tmp_path / "notebooks"

shutil.copytree(str(source_path), str(repo_path))
Expand Down Expand Up @@ -297,7 +298,7 @@ async def test_exclude_dirs(
cwd = Path.cwd()

# Set up a notebook repository.
source_path = Path(__file__).parent.parent / "notebooks_recursive"
source_path = TEST_DATA_DIR / "notebooks_recursive"
repo_path = tmp_path / "notebooks"

shutil.copytree(str(source_path), str(repo_path))
Expand Down Expand Up @@ -396,7 +397,7 @@ async def test_alert(
mock_gafaelfawr(respx_mock)

# Set up a notebook repository with the exception notebook.
source_path = Path(__file__).parent.parent / "notebooks_recursive"
source_path = TEST_DATA_DIR / "notebooks_recursive"
repo_path = tmp_path / "notebooks"
repo_path.mkdir()
shutil.copy(str(source_path / "exception.ipynb"), str(repo_path))
Expand Down
5 changes: 2 additions & 3 deletions tests/handlers/github_ci_app_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import hashlib
import hmac
from dataclasses import dataclass
from pathlib import Path
from string import Template

import pytest
Expand All @@ -13,7 +12,7 @@

from mobu.services.github_ci.ci_manager import CiManager

from ..support.constants import TEST_GITHUB_CI_APP_SECRET
from ..support.constants import TEST_DATA_DIR, TEST_GITHUB_CI_APP_SECRET
from ..support.gafaelfawr import mock_gafaelfawr


Expand All @@ -33,7 +32,7 @@ def webhook_request(
with_prs: bool = True,
) -> GitHubRequest:
"""Build a GitHub webhook request and headers with the right hash."""
data_path = Path(__file__).parent.parent / "data" / "github_webhooks"
data_path = TEST_DATA_DIR / "github_webhooks"
suffix = "_no_prs" if not with_prs else ""
template = (data_path / f"{event}_{action}{suffix}.tmpl.json").read_text()
payload = Template(template).substitute(
Expand Down
5 changes: 2 additions & 3 deletions tests/handlers/github_refresh_app_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
import hashlib
import hmac
from dataclasses import dataclass
from pathlib import Path
from string import Template

import pytest
import respx
from httpx import AsyncClient
from pytest_mock import MockerFixture

from ..support.constants import TEST_GITHUB_REFRESH_APP_SECRET
from ..support.constants import TEST_DATA_DIR, TEST_GITHUB_REFRESH_APP_SECRET
from ..support.gafaelfawr import mock_gafaelfawr


Expand All @@ -23,7 +22,7 @@ class GithubRequest:

def webhook_request(org: str, repo: str, ref: str) -> GithubRequest:
"""Build a Github webhook request and headers with the right hash."""
data_path = Path(__file__).parent.parent / "data" / "github_webhooks"
data_path = TEST_DATA_DIR / "github_webhooks"
template = (data_path / "push.tmpl.json").read_text()
payload = Template(template).substitute(org=org, repo=repo, ref=ref)

Expand Down
5 changes: 5 additions & 0 deletions tests/support/constants.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
"""Constants used in text fixtures and setup."""

from pathlib import Path

TEST_BASE_URL = "https://example.com"
"""Base URL used for the test `httpx.AsyncClient`."""

TEST_DATA_DIR = Path(__file__).parent.parent / "data"
"""Directory that contains test data."""

TEST_GITHUB_REFRESH_APP_SECRET = "some-webhook-secret"
"""Webhook secret used for hashing test github refresh app webhook payloads."""

Expand Down