Skip to content

Commit

Permalink
🧪 updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juftin committed Feb 27, 2024
1 parent c4b5489 commit 819659d
Show file tree
Hide file tree
Showing 7 changed files with 400 additions and 353 deletions.
695 changes: 347 additions & 348 deletions tests/__snapshots__/test_screenshots.ambr

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pathlib
from typing import Any, Dict, List

import pyperclip
import pytest
from click.testing import CliRunner
from textual_universal_directorytree import GitHubPath
Expand Down Expand Up @@ -44,6 +45,16 @@ def github_release_path() -> GitHubPath:
return GitHubPath(uri)


@pytest.fixture(autouse=True)
def copy_supported(monkeypatch: pytest.MonkeyPatch) -> None:
"""
Override _copy_supported
"""
monkeypatch.setattr(
pyperclip, "determine_clipboard", lambda: (lambda: True, lambda: True)
)


@pytest.fixture(scope="module")
def vcr_config() -> Dict[str, List[Any]]:
"""
Expand Down
19 changes: 19 additions & 0 deletions tests/debug_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
App Debugging
"""

import pytest

from browsr.base import TextualAppContext
from browsr.browsr import Browsr


@pytest.mark.asyncio
async def test_debug_app() -> None:
"""
Test the actual browsr app
"""
config = TextualAppContext(file_path="s3:https://", debug=True)
app = Browsr(config_object=config)
async with app.run_test() as pilot:
_ = pilot.app
18 changes: 18 additions & 0 deletions tests/test_browsr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""
Test the actual browsr app
"""

import pytest

from browsr.base import TextualAppContext
from browsr.browsr import Browsr


def test_bad_path() -> None:
"""
Test a bad path
"""
with pytest.raises(FileNotFoundError):
_ = Browsr(
config_object=TextualAppContext(file_path="bad_file_path.csv", debug=True)
)
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from click.testing import CliRunner

from browsr._cli import browsr
from browsr.cli import browsr


def test_cli_main(runner: CliRunner) -> None:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

from textual_universal_directorytree import GitHubPath

from browsr._base import TextualAppContext
from browsr._config import favorite_themes
from browsr.base import TextualAppContext
from browsr.config import favorite_themes
from tests.conftest import cassette


Expand Down
4 changes: 2 additions & 2 deletions tests/test_screenshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
@pytest.fixture
def app_file() -> str:
file_content = """
from browsr import Browsr
from browsr._base import TextualAppContext
from browsr.browsr import Browsr
from browsr.base import TextualAppContext
file_path = "{file_path}"
context = TextualAppContext(file_path=file_path)
Expand Down

0 comments on commit 819659d

Please sign in to comment.