Last active
December 31, 2024 23:12
-
-
Save elyssonmr/db881d61791c1cfca3f5ba6e4d1d2592 to your computer and use it in GitHub Desktop.
Cenário 1 do artigo: https://elyssonmr.com/blog/posts/20241231_tests_hints/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def save_pokemon_name(pokemon_name: str): | |
# Should save pokemon name in database | |
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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