Skip to content

Instantly share code, notes, and snippets.

@elyssonmr
Last active December 31, 2024 23:12
Show Gist options
  • Save elyssonmr/db881d61791c1cfca3f5ba6e4d1d2592 to your computer and use it in GitHub Desktop.
Save elyssonmr/db881d61791c1cfca3f5ba6e4d1d2592 to your computer and use it in GitHub Desktop.
def save_pokemon_name(pokemon_name: str):
# Should save pokemon name in database
pass
from scenario1.database import save_pokemon_name
def save_pokemons_name(pokemons_names: list[str]):
for pokemon_name in pokemons_names:
save_pokemon_name(pokemon_name=pokemon_name)
from unittest.mock import patch
import pytest
from scenario1.helpers import save_pokemons_name
@pytest.fixture
def mock_save_pokemon_name():
with patch('scenario1.helpers.save_pokemon_name') as patched:
yield patched
def test_should_save_pokemons(mock_save_pokemon_name):
pokemons_names = ['Bulbasaur']
save_pokemons_name(pokemons_names)
mock_save_pokemon_name.assert_called_once_with(
pokemon_name=pokemons_names[0]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment