Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fshowalter committed Dec 8, 2023
1 parent 1dbce64 commit 637e17d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
50 changes: 30 additions & 20 deletions tests/cli/test_imdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,56 @@


@pytest.fixture(autouse=True)
def mock_refresh_core_data(mocker: MockerFixture) -> MagicMock:
return mocker.patch("movielog.cli.imdb.movielog_api.refresh_core_data")
def mock_update_datasets(mocker: MockerFixture) -> MagicMock:
return mocker.patch("movielog.cli.imdb.repository_api.update_datasets")


@pytest.fixture(autouse=True)
def mock_refresh_credits(mocker: MockerFixture) -> MagicMock:
return mocker.patch("movielog.cli.imdb.movielog_api.refresh_credits")
def mock_update_title_data(mocker: MockerFixture) -> MagicMock:
return mocker.patch("movielog.cli.imdb.repository_api.update_title_data")


def test_calls_refresh_core_data(
mock_input: MockInput, mock_refresh_core_data: MagicMock
@pytest.fixture(autouse=True)
def mock_update_watchlist_credits(mocker: MockerFixture) -> MagicMock:
return mocker.patch("movielog.cli.imdb.repository_api.update_watchlist_credits")


@pytest.fixture(autouse=True)
def mock_validate_data(mocker: MockerFixture) -> MagicMock:
return mocker.patch("movielog.cli.imdb.repository_api.validate_data")


def test_calls_update_daasets(
mock_input: MockInput, mock_update_datasets: MagicMock
) -> None:
mock_input([Down, Enter, "y", Enter, Escape])
mock_input([Enter, Escape, Escape])
imdb.prompt()

mock_refresh_core_data.assert_called_once()
mock_update_datasets.assert_called_once()


def test_can_confirm_refresh_core_data(
mock_input: MockInput, mock_refresh_core_data: MagicMock
def test_calls_mock_update_title_data(
mock_input: MockInput, mock_update_title_data: MagicMock
) -> None:
mock_input([Down, Enter, "n", Enter, Escape])
mock_input([Down, Enter, Escape, Escape])
imdb.prompt()

mock_refresh_core_data.assert_not_called()
mock_update_title_data.assert_called_once()


def test_calls_refresh_credits(
mock_input: MockInput, mock_refresh_credits: MagicMock
def test_calls_update_watchlist_credits(
mock_input: MockInput, mock_update_watchlist_credits: MagicMock
) -> None:
mock_input([Down, Down, Enter, "y", Enter, Escape])
mock_input([Down, Down, Enter, Escape, Escape])
imdb.prompt()

mock_refresh_credits.assert_called_once()
mock_update_watchlist_credits.assert_called_once()


def test_can_confirm_refresh_credits(
mock_input: MockInput, mock_refresh_credits: MagicMock
def test_calls_validate_data(
mock_input: MockInput, mock_validate_data: MagicMock
) -> None:
mock_input([Down, Down, Enter, "n", Enter, Escape])
mock_input([Down, Down, Down, Enter, Escape, Escape])
imdb.prompt()

mock_refresh_credits.assert_not_called()
mock_validate_data.assert_called_once()
2 changes: 1 addition & 1 deletion tests/cli/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from movielog.cli import main
from tests.cli.conftest import MockInput
from tests.cli.keys import Down, End, Enter, Escape, Up
from tests.cli.keys import Down, Enter, Escape, Up


@pytest.fixture(autouse=True)
Expand Down

0 comments on commit 637e17d

Please sign in to comment.